March 27, 2018
Iterators iterate myArray = [‘one’, ‘two’, ‘three’]; .forEach() myArray.forEach(function(myArrayItem) { console.log(myArrayItem); }); myArray.forEach((myArrayItem) => { console.log(myArrayItem); }); .map() Iterates and CHANGES the contents of an array, maps it to another array let numbers = [1, 2, 3, 4, 5]; let bigNumbers = numbers.map(function(number) { return number * 10; }); let numbers = [1, 2, 3, […]
March 26, 2018
for loops, which let us loop a block of code a known amount of times. let myArray = [‘one’, ‘two’, ‘three’, ‘four’]; for (let i = 0; i<myArray.length; i++) { console.log(myArray[i]); } let i = 0; is the start condition – loop will start at 0 i is the iterator variable i<myArray.length is the stop […]
THE TERMINAL I know all this, must making notes the “$” is a “shell prompt” – never knew what that was called pwd is “Print working directory” mkdir makes a directory touch creates a file ……………………….. The command line is a text interface for the computer’s operating system. To access the command line, we use […]
Array methods – functions that manipulate array contents. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array let myArray = [‘item one’, ‘item two’, ‘item three’] const myArray = [‘item one’, ‘item two’, ‘item three’] if you use const, you cannot change the data type but you CAN manipulate the array in any way. Each item has a numbered position JS starts counting […]
Iterators iterate myArray = [‘one’, ‘two’, ‘three’]; .forEach() myArray.forEach(function(myArrayItem) { console.log(myArrayItem); }); myArray.forEach((myArrayItem) => { console.log(myArrayItem); }); .map() Iterates and CHANGES the contents of the array Powered by WPeMatico