Javascript: Iterators Lesson 3 .map()


#1

So one, the solution for this finishes the whole thing for you instead of walking you through it and introduces another thing call .charAt or something in the solution which I find stupid since the lesson doesn’t introduce that, but anyway:

I have no idea how to go about this lesson, if anyone could help me that’d be great. So far I’ve gotten:

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

// Create the secretMessage array below
let animals = animals.map(function(animal){
  return animal [0];
  let secretMessage = animal;
});

console.log(secretMessage.join(''));

let bigNumbers = [100, 200, 300, 400, 500];

// Create the smallNumbers array below

I really have no idea how to get the message to print. The example isn’t a 1:1 scale thing for the operation so I’m kind of stuck.

Actually from looking at similar topics it looks like the rest of the course is broken since this introduces .charAt as a requirement so I guess I’ll go to freecodecamp then, good thing I didn’t give 200 bucks for this shill.


#2

i have completed the courses? What is broken then? I have been on the forum long enough to see that most times its a mistake in the users code

as for your code, you don’t have to use use charAt, you can also use [0] or google how to use a function like charAt. Google is your friend.

here:

let animals = animals.map(function(animal)

why do you have let animals? this is the variable which stored the returned result of the map function, so i would name this variable secretMessage

you can’t do this inside the .map() function, return will end the function callback, so any code after return is never reached


#3

A post was split to a new topic: Javascript iterators lesson 3 map