This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var students = [ | |
| {name: 'adam', age: 18}, | |
| {name: 'brian', age: 20}, | |
| {name: 'charles', age: 24} | |
| ]; | |
| var allLarestStudents = true; | |
| for (var i = 0; i <students.length; i ++) { | |
| if (students [i] age <18) { | |
| allLarestStudents = false; | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var students = [ | |
| {name: 'adam', age: 18}, | |
| {name: 'brian', age: 20}, | |
| {name: 'charles', age: 24} | |
| ]; | |
| var allLarestStudents = students.every (function (student) { | |
| return student.ity> = 18; | |
| }); | |
| console.log (allBiggest Students); // true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var weightMascases = [12,32,21,29]; | |
| var hasWeightPacking = false; | |
| for (var i = 0; i <weightMas.length; i ++) { | |
| if (weightOf Bags [i]> 30) { | |
| hasMaleOverWeight = true; | |
| } | |
| } | |
| console.log (hasPlantLightTable); // true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var weightMascases = [12,32,21,29]; | |
| var hasLightOverWeight = bagWeight.some (function (bagWeight) { | |
| returnMachineWeight> 30; | |
| }); | |
| console.log (hasPlantLightTable); // true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var numbers = [1,2,3,4,5]; | |
| var sum = 0; | |
| for (var i = 0; i <numbers.length; i ++) { | |
| sum + = numbers [i]; | |
| } | |
| console.log (sum); // 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var numbers = [1,2,3,4,5]; | |
| var sum = 0; | |
| sum = numbers.reduce (function (sum, number) { | |
| return sum + number; | |
| }, 0) | |
| console.log (sum); // 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var students = [ | |
| {name: 'adam', age: 10}, | |
| {name: 'brian', age: 20}, | |
| {name: 'charles', age: 30} | |
| ]; | |
| var names = students.reduce (function (arrayNames, student) { | |
| arrayNames.push (student.name); | |
| return array Names; | |
| }, []); | |
| console.log (names); // ['adam', 'brian', 'charles'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var witches = ['Harry Potter', 'Hermione Granger', 'Ron Weasley']; | |
| // get the iterator | |
| var iteratorWitches = witches [Symbol.iterator] (); | |
| iteratorWow.next (); // {value: Harry Potter, done: false} | |
| iteratorWow.next (); // {value: Hermione Granger, done: false} | |
| iteratorWow.next (); // {value: Ron Weasley, done: false} | |
| iteratorWow.next (); // {value: undefined, done: true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var iterator = witches [Symbol.iterator] (); | |
| var done = false; | |
| var next = iterator.next (); | |
| of { | |
| var wizard = next.value; | |
| hatSelectorMakeHouseSelection (wizard); | |
| next = iterator.next (); | |
| } while (! next.done); | |
| Assuming that the doSelectionDomain method displays on the console the student's name and their home, using our list of wizards from the previous example in this algorithm, we have as output: | |
| student: Harry Potter | House: Gryffindor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var map = new Map (); | |
| function function () {}; | |
| var object = {}; | |
| map.set ("string", "I'm a string"); | |
| map.set (object, "I am an object"); | |
| map.set (function, "I am a function"); |