help with exercise 2 in JS Assignment 10: Array Properties and Methods
HannahB593 (1)

I'm really stuck on this question- the rest i understand and have correctly. Just not sure what's wrong with two.

This is what I have:

function exerciseTwo(snacks){
let favoriteSnack= 'grapes';
snacks.push = (favoriteSnack (or grapes?) ;
return snacks;
}

before i added "let favoriteSnack" i had gotten the error saying "grapes is undefined."- so that's why i tried to use that. been looking for clues but unsure- can anyone help ?

You are viewing a single comment. View All
Highwayman (38)

Snacks.push(favoriteSnack); maybe instead of snacks.push = (favoriteSnack); ?
Edit: or snacks.push('grapes');

mwilki7 (281)

@Highwayman the first one is correct i think

Giothecoder (13)

@mwilki7 I’m pretty sure they want something like the second though.

because look he says 'grapes' and never makes the var?

HannahB593 (1)

excellent! This worked, thank you. That makes sense considering unshift has 1 in exercise 4 for example, which is just in parentheses just like 'grapes' is in this exercise. @Highwayman