-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.ts
35 lines (20 loc) · 821 Bytes
/
array.ts
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
let shoppingList: string[] = ["milk", "chocolate" , "shampoo"];
// PRINT ALL LIST
//console.log("List: " + shoppingList);
//console.log("=====ADDING==========");
shoppingList.push("Safeguard");
//console.log("CREATE_ shopping list is now " + shoppingList);
// FETCHING SPECIFIC INDEX
//console.log("=====FETCHING==========");
let firstItem = shoppingList[0];
let secondItem = shoppingList[1];
//console.log("First Item: " + firstItem);
//console.log("Second Item: " + secondItem);
// UPDATING
//console.log("=====UPDATING==========");
shoppingList[1] = "strawberry";
//console.log("UPDATING_ shopping list is now " + shoppingList);
//REMOVING
console.log("======DELETING==========");
shoppingList.splice(2, 1); //Remove 1 item at index 2
console.log("DELETING_ shopping list is now " + shoppingList);