Week 3 Review Flashcards
Review Week 3 Readings and FCC
Loop over an array using “for”.
for (let i = 0; i < myArray.length; i++) { // Use myArray[i] to access each array element one by one }
Loop over an array using for each
myArray.forEach(myElement => { // Use myElement to access each array element one by one });
Loop through an array using for-of
for (const myElement of myArray) { // Use myElement to access each array element one by one }
Remove the 2nd, 3rd, and 4th element using splice
myArray.splice(1,3)
Splice syntax
Splice method with index of first element and second parameter is how many elements to remove
TF Strings are objects with methods and properties
True
TF A javascript string is immutable
True
Convert a string to lower case
myString.toLowerCase()
Convert a string to upper case
myString.toUpperCase
TF You can use == to compare two strings
False use ===
Access each letter of a string
for (let i = 0; i < myString.length; i++) { Console.log(myString[1]); }
Access each letter of a string using for of
const name = "Sarah"; for (const letter of name) { console.log(letter); }
Turn a string into an array
const name = "Sarah"; const nameArray = Array.from(name);
What does
const song = “Honky Tonk Women”;
console.log(song.indexOf(“Onk”));
Return
-1 because string not found because case mismatch
Break a string apart into array
myString = ’Jan, 12’
myString.split(“,“)
Find index of ‘r’ in string “Forrest”
myString = “Forrest”;
myString.indexOf(“r”);
Object Orientated Programming or OOP is a programming ________________
paradigm
A JavaScript class is defined with the ________ keyword.
class
What method is called during object creation
constructor()
The keyword that represents the object on which a method was called
this
Objects are created from a class with the _______ operator
new
Javascripts OOP model is based on ___________
prototypes
When trying to access a property that does not exist in an object, JavaScript then tries to find the property by in the ________ ________
prototype chain
The method used to create a link between objects through prototypes
Object.create()
TF A JavaScript class can only contain methods
True
Functional programing is combining functions expressing ________ to do not ___________
what how
The state of a program is the value of its __________ _________ at a given time.
global variables
A pure function depends solely on its ___________ for computing its outputs
inputs
A ______ . _______ is achange in a program state or interaction with the outside world
side effect
Given the same data, a pure function will always produce the ___________ __________
same result
The __________ method takes an array as a parameter and creates a new array with the results of calling a new function
map()
The ___________ method offers a way to test every element of an array against a provided function. Only elements that pass this test are added to the returned array.
filter()
The _________ method applied a provided function to each array element in order to reduce it to one value.
reduce()
TF JavaScript is a multi-paradigm language
True