Iterators bug?


#1

when I run the following code it throws ‘Did you put ‘word => word.length > 5’ inside of the parentheses?’
what am I missing here?

let words = ['unique', 'uncanny', 'pique', 'oxymoron', 'guise'];

// Something is missing in the method call below

console.log(words.some(function(word) {
  return word.length < 6;
}));

// Use filter to create a new array
let interestingWords = words.filter(word => word.length > 5);
console.log(interestingWords);


// Make sure to uncomment the code below and fix the incorrect code before running it

console.log(interestingWords.every(word => typeof 'string'));

#2

can you please share exercise url?

it seems the exercise wants you to use the shorthand (word => word.length > 5) and not the full out written function like you did


#3

https://www.codecademy.com/courses/learn-javascript-iterators/lessons/javascript-iterators/exercises/documentation?action=resume_content_item&course_redirect=introduction-to-javascript


#4

the last line of your code:

console.log(interestingWords.every(word => typeof 'string'));

although true is returned, its not what the exercise had in mind, you have to use word.length > 5 like shown in the error message


#5

Oh Ok. I thought it was giving me an error for the function on line 10. Not that last one. Thank you.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.