From 3a5b27352054fc09c426eab67a54089af7bf4cc1 Mon Sep 17 00:00:00 2001 From: Karan <50290386+Sonawane-Karan26@users.noreply.github.com> Date: Wed, 24 Nov 2021 19:19:10 +0530 Subject: [PATCH] Exercise 3.2 --- Chapter 3/Exercise 3.2 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Chapter 3/Exercise 3.2 diff --git a/Chapter 3/Exercise 3.2 b/Chapter 3/Exercise 3.2 new file mode 100644 index 0000000..5d09742 --- /dev/null +++ b/Chapter 3/Exercise 3.2 @@ -0,0 +1,12 @@ +const myList = []; +myList.push("Milk", "Bread", "Apples"); +myList.splice(1, 1, "Bananas", "Eggs"); +const removeLast = myList.pop(); +console.log(removeLast); +myList.sort(); +console.log(myList.indexOf("Milk")); +myList.splice(1, 0, "Carrots", "Lettuce"); +const myList2 = ["Juice", "Pop"]; +const finalList = myList.concat(myList2, myList2); +console.log(finalList.lastIndexOf("Pop")); +console.log(finalList);