Skip to content

Commit e827703

Browse files
committed
reformats arrays.js
1 parent 5bccebe commit e827703

File tree

1 file changed

+59
-60
lines changed

1 file changed

+59
-60
lines changed

assignments/arrays.js

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@
22

33
// The car dealer has all of their inventory housed in the array seen below. Scroll down past the data to find out how you can help the car dealer.
44

5-
let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year":2009},
6-
{"id":2,"car_make":"Mazda","car_model":"Miata MX-5","car_year":2001},
7-
{"id":3,"car_make":"Land Rover","car_model":"Defender Ice Edition","car_year":2010},
8-
{"id":4,"car_make":"Honda","car_model":"Accord","car_year":1983},
9-
{"id":5,"car_make":"Mitsubishi","car_model":"Galant","car_year":1990},
10-
{"id":6,"car_make":"Honda","car_model":"Accord","car_year":1995},
11-
{"id":7,"car_make":"Smart","car_model":"Fortwo","car_year":2009},
12-
{"id":8,"car_make":"Audi","car_model":"4000CS Quattro","car_year":1987},
13-
{"id":9,"car_make":"Ford","car_model":"Windstar","car_year":1996},
14-
{"id":10,"car_make":"Mercedes-Benz","car_model":"E-Class","car_year":2000},
15-
{"id":11,"car_make":"Infiniti","car_model":"G35","car_year":2004},
16-
{"id":12,"car_make":"Lotus","car_model":"Esprit","car_year":2004},
17-
{"id":13,"car_make":"Chevrolet","car_model":"Cavalier","car_year":1997},
18-
{"id":14,"car_make":"Dodge","car_model":"Ram Van 1500","car_year":1999},
19-
{"id":15,"car_make":"Dodge","car_model":"Intrepid","car_year":2000},
20-
{"id":16,"car_make":"Mitsubishi","car_model":"Montero Sport","car_year":2001},
21-
{"id":17,"car_make":"Buick","car_model":"Skylark","car_year":1987},
22-
{"id":18,"car_make":"Geo","car_model":"Prizm","car_year":1995},
23-
{"id":19,"car_make":"Oldsmobile","car_model":"Bravada","car_year":1994},
24-
{"id":20,"car_make":"Mazda","car_model":"Familia","car_year":1985},
25-
{"id":21,"car_make":"Chevrolet","car_model":"Express 1500","car_year":2003},
26-
{"id":22,"car_make":"Jeep","car_model":"Wrangler","car_year":1997},
27-
{"id":23,"car_make":"Eagle","car_model":"Talon","car_year":1992},
28-
{"id":24,"car_make":"Toyota","car_model":"MR2","car_year":2003},
29-
{"id":25,"car_make":"BMW","car_model":"525","car_year":2005},
30-
{"id":26,"car_make":"Cadillac","car_model":"Escalade","car_year":2005},
31-
{"id":27,"car_make":"Infiniti","car_model":"Q","car_year":2000},
32-
{"id":28,"car_make":"Suzuki","car_model":"Aerio","car_year":2005},
33-
{"id":29,"car_make":"Mercury","car_model":"Topaz","car_year":1993},
34-
{"id":30,"car_make":"BMW","car_model":"6 Series","car_year":2010},
35-
{"id":31,"car_make":"Pontiac","car_model":"GTO","car_year":1964},
36-
{"id":32,"car_make":"Dodge","car_model":"Ram Van 3500","car_year":1999},
37-
{"id":33,"car_make":"Jeep","car_model":"Wrangler","car_year":2011},
38-
{"id":34,"car_make":"Ford","car_model":"Escort","car_year":1991},
39-
{"id":35,"car_make":"Chrysler","car_model":"300M","car_year":2000},
40-
{"id":36,"car_make":"Volvo","car_model":"XC70","car_year":2003},
41-
{"id":37,"car_make":"Oldsmobile","car_model":"LSS","car_year":1997},
42-
{"id":38,"car_make":"Toyota","car_model":"Camry","car_year":1992},
43-
{"id":39,"car_make":"Ford","car_model":"Econoline E250","car_year":1998},
44-
{"id":40,"car_make":"Lotus","car_model":"Evora","car_year":2012},
45-
{"id":41,"car_make":"Ford","car_model":"Mustang","car_year":1965},
46-
{"id":42,"car_make":"GMC","car_model":"Yukon","car_year":1996},
47-
{"id":43,"car_make":"Mercedes-Benz","car_model":"R-Class","car_year":2009},
48-
{"id":44,"car_make":"Audi","car_model":"Q7","car_year":2012},
49-
{"id":45,"car_make":"Audi","car_model":"TT","car_year":2008},
50-
{"id":46,"car_make":"Oldsmobile","car_model":"Ciera","car_year":1995},
51-
{"id":47,"car_make":"Volkswagen","car_model":"Jetta","car_year":2007},
52-
{"id":48,"car_make":"Dodge","car_model":"Magnum","car_year":2008},
53-
{"id":49,"car_make":"Chrysler","car_model":"Sebring","car_year":1996},
54-
{"id":50,"car_make":"Lincoln","car_model":"Town Car","car_year":1999}];
5+
let inventory = [{"id": 1, "car_make": "Lincoln", "car_model": "Navigator", "car_year": 2009},
6+
{"id": 2, "car_make": "Mazda", "car_model": "Miata MX-5", "car_year": 2001},
7+
{"id": 3, "car_make": "Land Rover", "car_model": "Defender Ice Edition", "car_year": 2010},
8+
{"id": 4, "car_make": "Honda", "car_model": "Accord", "car_year": 1983},
9+
{"id": 5, "car_make": "Mitsubishi", "car_model": "Galant", "car_year": 1990},
10+
{"id": 6, "car_make": "Honda", "car_model": "Accord", "car_year": 1995},
11+
{"id": 7, "car_make": "Smart", "car_model": "Fortwo", "car_year": 2009},
12+
{"id": 8, "car_make": "Audi", "car_model": "4000CS Quattro", "car_year": 1987},
13+
{"id": 9, "car_make": "Ford", "car_model": "Windstar", "car_year": 1996},
14+
{"id": 10, "car_make": "Mercedes-Benz", "car_model": "E-Class", "car_year": 2000},
15+
{"id": 11, "car_make": "Infiniti", "car_model": "G35", "car_year": 2004},
16+
{"id": 12, "car_make": "Lotus", "car_model": "Esprit", "car_year": 2004},
17+
{"id": 13, "car_make": "Chevrolet", "car_model": "Cavalier", "car_year": 1997},
18+
{"id": 14, "car_make": "Dodge", "car_model": "Ram Van 1500", "car_year": 1999},
19+
{"id": 15, "car_make": "Dodge", "car_model": "Intrepid", "car_year": 2000},
20+
{"id": 16, "car_make": "Mitsubishi", "car_model": "Montero Sport", "car_year": 2001},
21+
{"id": 17, "car_make": "Buick", "car_model": "Skylark", "car_year": 1987},
22+
{"id": 18, "car_make": "Geo", "car_model": "Prizm", "car_year": 1995},
23+
{"id": 19, "car_make": "Oldsmobile", "car_model": "Bravada", "car_year": 1994},
24+
{"id": 20, "car_make": "Mazda", "car_model": "Familia", "car_year": 1985},
25+
{"id": 21, "car_make": "Chevrolet", "car_model": "Express 1500", "car_year": 2003},
26+
{"id": 22, "car_make": "Jeep", "car_model": "Wrangler", "car_year": 1997},
27+
{"id": 23, "car_make": "Eagle", "car_model": "Talon", "car_year": 1992},
28+
{"id": 24, "car_make": "Toyota", "car_model": "MR2", "car_year": 2003},
29+
{"id": 25, "car_make": "BMW", "car_model": "525", "car_year": 2005},
30+
{"id": 26, "car_make": "Cadillac", "car_model": "Escalade", "car_year": 2005},
31+
{"id": 27, "car_make": "Infiniti", "car_model": "Q", "car_year": 2000},
32+
{"id": 28, "car_make": "Suzuki", "car_model": "Aerio", "car_year": 2005},
33+
{"id": 29, "car_make": "Mercury", "car_model": "Topaz", "car_year": 1993},
34+
{"id": 30, "car_make": "BMW", "car_model": "6 Series", "car_year": 2010},
35+
{"id": 31, "car_make": "Pontiac", "car_model": "GTO", "car_year": 1964},
36+
{"id": 32, "car_make": "Dodge", "car_model": "Ram Van 3500", "car_year": 1999},
37+
{"id": 33, "car_make": "Jeep", "car_model": "Wrangler", "car_year": 2011},
38+
{"id": 34, "car_make": "Ford", "car_model": "Escort", "car_year": 1991},
39+
{"id": 35, "car_make": "Chrysler", "car_model": "300M", "car_year": 2000},
40+
{"id": 36, "car_make": "Volvo", "car_model": "XC70", "car_year": 2003},
41+
{"id": 37, "car_make": "Oldsmobile", "car_model": "LSS", "car_year": 1997},
42+
{"id": 38, "car_make": "Toyota", "car_model": "Camry", "car_year": 1992},
43+
{"id": 39, "car_make": "Ford", "car_model": "Econoline E250", "car_year": 1998},
44+
{"id": 40, "car_make": "Lotus", "car_model": "Evora", "car_year": 2012},
45+
{"id": 41, "car_make": "Ford", "car_model": "Mustang", "car_year": 1965},
46+
{"id": 42, "car_make": "GMC", "car_model": "Yukon", "car_year": 1996},
47+
{"id": 43, "car_make": "Mercedes-Benz", "car_model": "R-Class", "car_year": 2009},
48+
{"id": 44, "car_make": "Audi", "car_model": "Q7", "car_year": 2012},
49+
{"id": 45, "car_make": "Audi", "car_model": "TT", "car_year": 2008},
50+
{"id": 46, "car_make": "Oldsmobile", "car_model": "Ciera", "car_year": 1995},
51+
{"id": 47, "car_make": "Volkswagen", "car_model": "Jetta", "car_year": 2007},
52+
{"id": 48, "car_make": "Dodge", "car_model": "Magnum", "car_year": 2008},
53+
{"id": 49, "car_make": "Chrysler", "car_model": "Sebring", "car_year": 1996},
54+
{"id": 50, "car_make": "Lincoln", "car_model": "Town Car", "car_year": 1999}];
5555

5656

5757
// Example for loop:
@@ -73,7 +73,7 @@ console.log(`${inventory[lastCar].car_make} ${inventory[lastCar].car_model}`);
7373
// ==== Challenge 3 ====
7474
// 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
7575
let carModels = [];
76-
for(let i = 0; i < inventory.length; i++){
76+
for (let i = 0; i < inventory.length; i++) {
7777
carModels.push(inventory[i].car_model);
7878
}
7979
//sorts car_model values of inventory alphabetically and console.logs the result
@@ -83,14 +83,12 @@ console.log(carModels.sort());
8383
console.log(carModels.length === inventory.length);
8484

8585

86-
87-
8886
// ==== Challenge 4 ====
8987
// 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.
9088
let carYears = [];
9189

9290
//adds year of each inventory item to carYears
93-
for(let i = 0; i < inventory.length; i++){
91+
for (let i = 0; i < inventory.length; i++) {
9492
carYears.push(inventory[i].car_year);
9593
}
9694

@@ -104,8 +102,8 @@ console.log(carYears.length === inventory.length);
104102
// 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.
105103
let oldCars = [];
106104

107-
for(let i = 0; i < carYears.length; i++){
108-
if(carYears[i] > 2000) {
105+
for (let i = 0; i < carYears.length; i++) {
106+
if (carYears[i] > 2000) {
109107
oldCars.push(carYears[i]);
110108
}
111109
}
@@ -116,10 +114,11 @@ console.log(oldCars.length);
116114
// Return an array that only contains BMW and Audi cars.
117115
// Once you have populated the BMWAndAudi array, use JSON.stringify() to show the results of the array in the console.
118116
let BMWAndAudi = [];
119-
for(let i = 0; i < inventory.length; i++) {
120-
if(inventory[i].car_make === "BMw" || inventory[i].car_make === "Audi") {
121-
BMWAndAudi.push(inventory[i]);
122-
} }
117+
for (let i = 0; i < inventory.length; i++) {
118+
if (inventory[i].car_make === "BMw" || inventory[i].car_make === "Audi") {
119+
BMWAndAudi.push(inventory[i]);
120+
}
121+
}
123122
console.log(JSON.stringify(BMWAndAudi));
124123

125124

0 commit comments

Comments
 (0)