Skip to content

Commit b750084

Browse files
sofialevinsofialevin
authored andcommitted
Completed Challenge 3 in arrays.js file.
1 parent fc87d8d commit b750084

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎assignments/arrays.js‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ for (let i = 0; i < inventory.length; i++) {
7474
// The dealer needs the information on the last car in their inventory. What is the make and model of the last car in the inventory? Log the make and model into the console.
7575
let lastCar = 0;
7676
lastCar = inventory.pop();
77-
console.log(lastCar.car_make + ' ' + lastCar.car_model);
77+
console.log(lastCar.car_make + ' ' + lastCar.car_model + '.');
7878

7979
// ==== Challenge 3 ====
8080
// 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
8181
let carModels = [];
82-
console.log();
82+
83+
for (let i = 0; i < inventory.length; i++) {
84+
carModels.push(inventory[i]['car_model']);
85+
}
86+
87+
console.log(carModels.sort());
8388

8489
// ==== Challenge 4 ====
8590
// 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.
@@ -94,7 +99,4 @@ console.log();
9499
// ==== Challenge 6 ====
95100
// A buyer is interested in seeing only BMW and Audi cars within the inventory. Return an array that only contains BMW and Audi cars. Once you have populated the BMWAndAudi array, use JSON.stringify() to show the results of the array in the console.
96101
let BMWAndAudi = [];
97-
console.log();
98-
99-
100-
102+
console.log();

0 commit comments

Comments
 (0)