Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
let numbers = [1,2,3,4,5,6,7]; | |
// replaced = [1,2,0,0,0,6,7] | |
let replaced = numbers.fill(0, 2, 5); |
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
let numbers = [1,2,3,4,5]; | |
let reducer = (previus, current) => previus + current; | |
// sum = 15 | |
let sum = numbers.reduce(reducer); |
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
let numbers = [1,2,3,4,5,6,7]; | |
// evens = [2,4,6] | |
let evens = numbers.filter(n => n % 2 == 0); |
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
let numbers = [1,2,3,4,5,6,7]; | |
// squared = [1,4,9,16,25,36,49] | |
let squared = numbers.map(n => n**2); |
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
let numbers = [1,3,5,6,7]; | |
// are_odds = false | |
let are_odds = numbers.every(n => n % 2 != 0); |
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
let numbers = [17,15,31,5,56]; | |
// over20 = true | |
let over20 = numbers.some(n => n > 20); |
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
let numbers = [2,4,6,8,10]; | |
// includes7 = false | |
let includes7 = numbers.includes(7); |
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
let pairs = [2,4,6,8,10]; | |
// multiple = 2 | |
let multiple = pairs.findIndex(n => n % 3 == 0); |
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
let numbers = [1,2,3,4,5,6,7]; | |
// even = 2 | |
let even = numbers.find(n => n % 2 == 0); |