renamed
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
const myList = ["Milk", "Bread", "Apples"];
|
||||
console.log(myList.length);
|
||||
myList[1] = "Bananas";
|
||||
console.log(myList);
|
||||
@@ -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);
|
||||
@@ -0,0 +1,5 @@
|
||||
const myArr = [1, 2, 3];
|
||||
const bigArr = [myArr, myArr, myArr];
|
||||
console.log(bigArr[1][1]);
|
||||
console.log(bigArr[0][1]);
|
||||
console.log(bigArr[2][1]);
|
||||
@@ -0,0 +1,15 @@
|
||||
const myCar = {
|
||||
make: "Toyota",
|
||||
model: "Camry",
|
||||
tires: 4,
|
||||
doors: 4,
|
||||
color: "blue",
|
||||
forSale: false
|
||||
};
|
||||
|
||||
let propColor = "color";
|
||||
myCar[propColor] = "red";
|
||||
propColor = "forSale";
|
||||
myCar[propColor] = true;
|
||||
console.log(myCar.make + " " + myCar.model);
|
||||
console.log(myCar.forSale);
|
||||
@@ -0,0 +1,6 @@
|
||||
const people = {friends:[]};
|
||||
const friend1 = {first: "Laurence", last: "Svekis", id: 1};
|
||||
const friend2 = {first: "Jane", last: "Doe", id: 2};
|
||||
const friend3 = {first: "John", last: "Doe", id: 3};
|
||||
people.friends.push(friend1, friend2, friend3);
|
||||
console.log(people);
|
||||
@@ -0,0 +1,7 @@
|
||||
theList.pop();
|
||||
theList.shift();
|
||||
theList.unshift("FIRST");
|
||||
theList[3] = "hello World";
|
||||
theList[2] = "MIDDLE";
|
||||
theList.push("LAST");
|
||||
console.log(theList);
|
||||
@@ -0,0 +1,22 @@
|
||||
const inventory = [];
|
||||
const item3 = {
|
||||
name: "computer",
|
||||
model: "imac",
|
||||
cost: 1000,
|
||||
qty: 3
|
||||
}
|
||||
const item2 = {
|
||||
name: "phone",
|
||||
model: "android",
|
||||
cost: 500,
|
||||
qty: 11
|
||||
}
|
||||
const item1 = {
|
||||
name: "tablet",
|
||||
model: "ipad",
|
||||
cost: 650,
|
||||
qty: 1
|
||||
}
|
||||
inventory.push(item1, item2, item3);
|
||||
console.log(inventory);
|
||||
console.log(inventory[2].qty);
|
||||
Reference in New Issue
Block a user