Iterator Documentation
Mon Jul 18 2022 21:18:51 GMT+0000 (Coordinated Universal Time)
Saved by
@cruz
#javascript
const words = ['unique', 'uncanny', 'pique', 'oxymoron', 'guise'];
// Something is missing in the method call below
console.log(words.some((word) => {
return word.length < 6;
}));
// Use filter to create a new array
const interestingWords = words.filter(words => {
return words.length > 5;
});
// Make sure to uncomment the code below and fix the incorrect code before running it
console.log(interestingWords.every((word) => {
return word.length > 5;
} ));
const cities = ['Orlando', 'Dubai', 'Edinburgh', 'Chennai', 'Accra', 'Denver', 'Eskisehir', 'Medellin', 'Yokohama'];
const nums = [1, 50, 75, 200, 350, 525, 1000];
// Choose a method that will return undefined
cities.forEach(city => console.log('Have you visited ' + city + '?'));
// Choose a method that will return a new array
const longCities = cities.filter(city => city.length > 7);
// Choose a method that will return a single value
const word = cities.reduce((acc, currVal) => {
return acc + currVal[0]
}, "C");
console.log(word)
// Choose a method that will return a new array
const smallerNums = nums.map(num => num - 5);
// Choose a method that will return a boolean value
nums.some(num => num < 0);
content_copyCOPY
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
https://www.codecademy.com/courses/introduction-to-javascript/lessons/javascript-iterators/exercises/documentation
Comments