-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (25 loc) · 982 Bytes
/
Copy pathscript.js
File metadata and controls
41 lines (25 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
console.log("Grocery shopping list");
const shoppingList = [];
console.log("It will be nice to have some fruit to eat.");
shoppingList.push("Apples");
function getShoppingListMsg() {
return `Current Shopping List: ${shoppingList}`;
}
console.log(getShoppingListMsg());
shoppingList.push("Grapes");
console.log(getShoppingListMsg());
console.log("It looks like we need to get some cooking oil.");
shoppingList.unshift("Vegetable Oil");
console.log(getShoppingListMsg());
shoppingList.push("Popcorn", "Beef Jerky", "Potato Chips");
console.log(getShoppingListMsg());
console.log("This looks like too much junk food.");
shoppingList.pop();
console.log(getShoppingListMsg());
console.log("It might be nice to get a dessert.");
shoppingList.unshift("Chocolate Cake");
console.log(getShoppingListMsg());
console.log("On second thought, maybe we should be more health conscious.");
shoppingList.shift();
shoppingList[0] = "Canola Oil";
console.log(getShoppingListMsg());