Learn JavaScript: Iterators 3/7 - .map()


#1

Hello. What is wrong with this arrow function syntax? (last two rows)

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

let animals = ['Hen', 'elephant', 'llama', 'leopard', 'ostrich', 'Whale', 'octopus', 'rabbit', 'lion', 'dog'];

let secretMessage = animals.map(function(animal) {
  return animal[0];
}); 

console.log(secretMessage.join(''));
let bigNumbers = [100, 200, 300, 400, 500];
let smallNumbers  = bigNumbers.map(function(number){
  return number / 100
});

animals.map(animalsItem => 
console.log (animalsItem[]));

#2

You are running the log method inside your function. That looks a little bit off.

Let’s refactor your other two functions…

const secretMessage = animals.map(animal => animal[0]);
const smallNumbers = bigNumbers.map(number => number / 100);

#3

3 posts were split to a new topic: Bug in iterators - map