Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4d4765

Browse files
committed
.
1 parent ebdf60a commit e4d4765

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

week2js/3tada15_17.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ o2.foo = 'chicken';
4848
console.log(o2);
4949
console.log(o3); // yes o3 has been changed//
5050
/* this is the same as question 15, o2 and o3 both point to the same box. so when you change the box
51-
contents, both o2 and o3 change because they are both pointing to that box.*/node
51+
contents, both o2 and o3 change because they are both pointing to that box.*/
5252

5353
// 17. type of//
5454
let bar = 42;

week2js/3tada6_11.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33

44
var vehicle = ["motorbike", "caravan", "bike", "scooter", "car", "truck"];
5-
var age = (age === 1) ? "new":"used";
5+
var age;
66

77
console.log(vehicle[5]);
8-
function vehicleType(color, age, vehicle){
9-
console.log("A " + color + " " + age + " " + vehicle);
8+
9+
function vehicleList(color, index, age){
10+
for(i =0; i<vehicle.length; i++)
11+
if(index === i ){
12+
(age => 2) ? console.log("A " + color + " new " + age) : console.log("A " + color + " used " + age);
13+
}
1014
}
11-
vehicleType("pink", "used", "car");
15+
vehicleList("pink", 0, vehicle[1]);
1216

1317
//7. list of vehicles//
1418
console.log(vehicle);
@@ -18,23 +22,14 @@ console.log(vehicle[2]);
1822

1923
//9.function vehicle//
2024
function getVehicle(color, index, age){
21-
for(i =0; i<vehicleType.length; i++)
25+
for(i =0; i<vehicle.length; i++)
2226
if(index === i ){
2327
(age < 1) ? console.log("A " + color + " new " + age) : console.log("A " + color + " used " + age);
2428
}
2529
}
2630
getVehicle("Green", 2, vehicle[3]);
2731

28-
/*try this code:
29-
function vehicles(color, code, age) {
30-
if (age > 1){
31-
console.log( 'a ' + color + ' used ' +list[code])
32-
} else if (age <= 1){
33-
console.log('a ' + color + ' new ' + list[code])
34-
}
35-
}
36-
console.log("vehicle('green', 3, 1) ===> " + vehicle("green", 3, 1));
37-
vehicles("green", 3, 1);*/
32+
3833

3934
//10. advertisement//
4035

0 commit comments

Comments
 (0)