You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The marketing team wants the car models listed alphabetically on the website. Sort all the car model names into alphabetical order and log the results in the console
88
-
letcarModels=[];
89
-
for(leti=0;i<inventory.length;i++){
90
-
carModels.push(inventory[i].car_model);
91
-
}
92
-
letcarModelsSorted=[];
93
-
for(leti=0;i<inventory.length;i++){
94
-
carModelsSorted.push(carModels[i]);
95
-
}
88
+
// let carModels = [];
89
+
// for (let i = 0; i < inventory.length; i++) {
90
+
// carModels.push(inventory[i].car_model);
91
+
// }
92
+
letcarModels=inventory.map(function(car){
93
+
returncar.car_model;
94
+
});
95
+
// let carModelsSorted = [];
96
+
// for (let i = 0; i < inventory.length; i++) {
97
+
// carModelsSorted.push(carModels[i]);
98
+
// }
99
+
letcarModelsSorted=carModels.map(function(model){
100
+
returnmodel;
101
+
});
96
102
carModelsSorted.sort();
97
103
console.log(carModels);
98
104
console.log(carModelsSorted);
99
105
100
106
// ==== Challenge 4 ====
101
107
// The accounting team needs all the years from every car on the lot. Create a new array from the dealer data containing only the car years and log the result in the console.
102
-
letcarYears=[];
103
-
for(leti=0;i<inventory.length;i++){
104
-
carYears.push(inventory[i].car_year);
105
-
}
108
+
// let carYears = [];
109
+
// for (let i = 0; i < inventory.length; i++) {
110
+
// carYears.push(inventory[i].car_year);
111
+
// }
112
+
letcarYears=inventory.map(function(car){
113
+
returncar.car_year;
114
+
});
106
115
console.log(carYears);
107
116
108
117
// ==== Challenge 5 ====
109
118
// The car lot manager needs to find out how many cars are older than the year 2000. Using the carYears array you just created, find out how many cars were made before the year 2000 by populating the array oldCars and logging it's length.
0 commit comments