I'm pretty much stuck at one of the last exercises at Lambda Pre-Course, JS assignment 16. Could anyone please give me any hints on what I'm doing wrong here?
RE: excerciseOne - I get the error message 'names' is not defined, although the array has been given. Also, putting the same code i wrote, in a different console (with the addition of creating an array called names of course) works perfectly! Is there an obvious point I'm missing here?
Please see the instructions and my solution below:
// Exercise One: In this exercise you will be given and array called names.
// Using the forEach method and a callback as it's only argument, console log
// each of the names.
Thank you very much for any help in advance!
If you read the problem description carefully, you'll see that the
names argument you get is the array you need to work on, but you're trying to use the
names argument outside the function. This doesn't work because the arguments passed into a function can only be used within the function, and not outside it like you've attempted to do on line 7.
Here are a couple of hints to help you out
- You need to put the
names.forEach(...)inside the exerciseOne function because you have to make use of the
namesarray within the function.
- You'll have to figure out what
...is exactly. If you are a little shaky on how
forEachworks, i suggest you to look up the documentation.
Let me know if i can help more :)