Skip to content

Commit 745ebca

Browse files
authored
Update week3.js
1 parent f18f53b commit 745ebca

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

week3.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ console.log(myString);
77

88
//Arrays
99
let favoriteAnimals = ["blowfish", "capricorn", "giraffe"];
10+
console.log(favoriteAnimals.push("turtle"));
1011
console.log(favoriteAnimals);
1112

12-
let favoriteAnimalsOfMauro = ["blowfish", "capricorn", "giraffe", "turtle"];
13-
console.log(favoriteAnimalsOfMauro);
13+
let addedAnimalOfJim = ["blowfish", "capricorn", "giraffe", "turtle"];
14+
console.log(addedAnimalOfJim.splice(1, 0, "meerkat"));
15+
console.log("The new value will be: ["blowfish", "meerkat", "capricorn", "giraffe", "turtle"]");
16+
console.log(addedAnimalOfJim);
17+
console.log("The array has a length of:", addedAnimalOfJim.length);
1418

15-
let favoriteAnimalsOfJim = ["blowfish", "meerkat", "capricorn", "giraffe", "turtle"];
16-
console.log("The favorite animal of Jim is added to the array.");
17-
console.log(favoriteAnimalsOfJim);
18-
console.log("The array has a length of:", favoriteAnimalsOfJim.length);
19-
20-
let favoriteAnimalsOfJason = ["blowfish", "meerkat", "capricorn", "turtle"];
21-
console.log(favoriteAnimalsOfJason);
22-
console.log(favoriteAnimalsOfJason.length);
23-
console.log(favoriteAnimalsOfJason[1], "The item you are looking for is at index:2");
19+
let deletedAnimalOfJason = ["blowfish", "meerkat", "capricorn", "giraffe", "turtle"];
20+
console.log(deletedAnimalOfJason.splice(-2, 1,));
21+
console.log(deletedAnimalOfJason.length);
22+
console.log(deletedAnimalOfJason[1], "The item you are looking for is at index:2");
2423

2524
//JavaScript
2625
function sum(a, b, c) {
@@ -34,9 +33,9 @@ function colorCar(color){
3433
console.log(colorCar("red"));
3534
//3.
3635
let country = {Land: "The Netherlands", Population:"17 million", Capital:"Amsterdam"};
37-
console.log(country);
38-
console.log(country.Land);
39-
console.log(country.Population);
36+
for (const elements in country) {
37+
console.log(country.elements = country[elements]);
38+
}
4039
//4.
4140
function vehicleType(color, code){
4241
if (code === 1){
@@ -128,4 +127,4 @@ typeof typeof bar;
128127
console.log(typeof bar); //->> number.
129128
console.log(typeof typeof bar); //->> string.
130129

131-
//the end.
130+
//the end.

0 commit comments

Comments
 (0)