Collections chapter - arrays

going through the second bullet - creating 3 prompts and placing answers in an array using the alert - my code is:

const food = prompt('fav food?');

const drink = prompt('fav drink?');

const desert = prompt('fav desert?');

const myArray = [food,drink,water];

alert(myArray);


the alert doesnt seem to work any ideas why?


Link to content: Learn to Code with JavaScript - Section 5

sorry just figured out my error in const myArray i put water which isnt defined

1 Like

You have,

But then you have

const myArray = [food,drink,water];

It’s this last line that is wrong. What do you see that’s different between these sets of lines? I’ll give you a hint. Look REALLY closely at how you named things - do they match?

As a tool, learn to use the dev tools in your browser. The error is shown in the console or if you click on the red X in the top right (the specific error you’re having is highlighted)

1 Like