diff --git a/pop/pop.js b/pop/pop.js new file mode 100644 index 0000000..0939fe0 --- /dev/null +++ b/pop/pop.js @@ -0,0 +1,4 @@ +let myHobby = ["play game","Harimau","read book"]; + +myHobby.pop(); +console.log(myHobby) \ No newline at end of file diff --git a/pop/study-case.js b/pop/study-case.js new file mode 100644 index 0000000..9ada348 --- /dev/null +++ b/pop/study-case.js @@ -0,0 +1,6 @@ +let animal = ["Singa", "Harimau", "Macan tutul"]; +function deleteLastIndex() { + return animal.pop(); +} +deleteLastIndex(); +console.log(animal); diff --git a/shift/shift.js b/shift/shift.js new file mode 100644 index 0000000..982e0fd --- /dev/null +++ b/shift/shift.js @@ -0,0 +1,4 @@ +let myHobby = ['game','Fishing',"Read Book"]; + +myHobby.shift(); +console.log(myHobby); \ No newline at end of file diff --git a/shift/study-case.js b/shift/study-case.js new file mode 100644 index 0000000..711d044 --- /dev/null +++ b/shift/study-case.js @@ -0,0 +1,7 @@ +let MyHobby = ["Running", "Hiking", "swimming"]; + +function deleteMyHobby() { + return MyHobby.shift(); +} +deleteMyHobby(); +console.log(MyHobby) \ No newline at end of file diff --git a/splice/splice.js b/splice/splice.js new file mode 100644 index 0000000..81b1f9e --- /dev/null +++ b/splice/splice.js @@ -0,0 +1,5 @@ +let animal = ['Kucing','Sapi','Kambing']; + +animal.splice(2,1); +animal.splice(0,0,"ikan pitek"); +console.log(animal); diff --git a/splice/study-case.js b/splice/study-case.js new file mode 100644 index 0000000..9e6ec25 --- /dev/null +++ b/splice/study-case.js @@ -0,0 +1,9 @@ +let animal = ["Singa","Harimau","Macan Tutul"]; + +function deleteElement(index, totalElement) { + return animal.splice(index,totalElement); +} + +deleteElement(1, 1); +console.log(animal); + diff --git a/unShift/study-case.js b/unShift/study-case.js new file mode 100644 index 0000000..5760119 --- /dev/null +++ b/unShift/study-case.js @@ -0,0 +1,7 @@ +let animal = ["Bebek", "Ayam", "Mentok", "Harimau"]; + +function AddAnimal() { + return animal.unshift("Jerapah", "Gajah"); +} +AddAnimal(); +console.log(animal); \ No newline at end of file diff --git a/unShift/unShift.js b/unShift/unShift.js new file mode 100644 index 0000000..c0836ba --- /dev/null +++ b/unShift/unShift.js @@ -0,0 +1,4 @@ +let animal = ["Sapi", "kerbau", "Buaya", "Harimau"]; +animal.unshift("Kelinci", "Zebra"); + +console.log(animal); \ No newline at end of file