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

Anonymous • 2 years 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);

Bella • 3 years ago

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

주하이나 • 3 years 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 • 2 years ago

thanks

Anonymous • 3 years ago

I need help

ubairnoor • 2 years 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);

https://codesandbox.io/s/co...

Tepz • 2 years 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);