We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Bella • 4 months ago

How do I play this? Should I just copy and paste?

주하이나 • 4 months ago

you can simply copy and past the code above , uncomment it and run it here https://onecompiler.com/jav...
just like this :

// create an array
let favoriteFoods = ["pizza", "tacos", "pasta"];

// change last element //
favoriteFoods[2] = "veggie burgers";
favoriteFoods[favoriteFoods.length - 1] = "veggie burgers";

// remove first element and store in variable
let formerFavoriteFood = favoriteFoods.shift();

// add to end of arrays
favoriteFoods.push("nachos");

// add to start of array
favoriteFoods.unshift("veggie platter");

// check
console.log("former favorite food removed:", formerFavoriteFood);
console.log(favoriteFoods);

sabbii • 3 months ago

thanks

Anonymous • 5 months ago

I need help

Tepz • 2 months ago

// create an array let favoriteFoods = ["pizza", "tacos", "pasta"];

// change last element // favoriteFoods[2] = "veggie burgers"; favoriteFoods[favoriteFoods.length - 1] = "veggie burgers";

// remove first element and store in variable let formerFavoriteFood = favoriteFoods.shift();

// add to end of arrays favoriteFoods.push("nachos");

// add to start of array favoriteFoods.unshift("veggie platter");

// check console.log(former favorite food removed: ${formerFavoriteFood}); console.log(favoriteFoods);