We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
How do I play this? Should I just copy and paste?
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);
thanks
I need help
// 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);
// 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);
// 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);