Skip to the content.

Popcorn Hacks Two


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']

desserts.splice(3, 1, "pie")
desserts.pop();
desserts.pop();
desserts.push("starburst");
desserts.push("brownie")

console.log(desserts.join(", "))
<IPython.core.display.Javascript object>

Popcorn Hack Two —


  • 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 list = [1, 2, 3, 4, 4, 5, 6, 7, 8, 10]; // create an variable 


const length = list.length; // create a const length


console.log(list); // print out your list in console
<IPython.core.display.Javascript object>