Popcorn Hacks One —
- Delete the last two items of the list below (delete1 and delete2)
- Change the non dessert item (fries) to a dessert
- Add two more desserts to list
%%js
let desserts = ['cake', 'ice cream', 'cookies', 'fries', 'delete1', 'delete2'] // list of desserts
desserts.splice(4, 2);//Deletes the 2 values of index 4 and after
desserts[3] = "brownie";//sets element 3 to be brownie
desserts.push("creme brulee", "almond jello");//adds creme brulee and almond jello to the end of the list
console.log(desserts.join(", "))//prints out desserts with a comma in between each of them
<IPython.core.display.Javascript object>
Popcorn Hacks Two —
Instructions:
- Create a length of a list and print it in console.log()
- Create a variable called “list” or “my_list_2”
- Create a list of numbers or words in the brackets [] Exp: let your_list = [3, 7, 9, 21];
- Create a const length = your_list.length;
- After all of that, finally print it out in console.log() Exp: console.log(your_list);
%%js
let pokemon = ["Ditto", "Vaporeon", "Articuno", "Snom"]; // create an variable
const length = pokemon.length; // create a const length
console.log(length);//prints out the length of the array
console.log(pokemon.join(", ")); // print out your list in console
<IPython.core.display.Javascript object>