diff --git a/README.md b/README.md index 9af84cbd5..8d7c785d1 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The [arrays.js](assignments/arrays.js) assignment takes us through a large data ### Stretch -* [ ] Arrow Function Syntax - [Check out this awesome guide for ES6 arrow syntax](https://medium.freecodecamp.org/when-and-why-you-should-use-es6-arrow-functions-and-when-you-shouldnt-3d851d7f0b26). You will see more and more arrow functions as you progress deeper into JavaScript. Use the [stretch-function-conversion.js](assignments/stretch-function-conversion.js) file as a helper challenge to showcase some of the differences between ES5 and ES6 syntax. +* [ ] Arrow Function Syntax - [Check out this awesome guide for ES6 arrow syntax](https://medium.freecodecamp.org/when-and-why-you-should-use-es6-arrow-functions-and-when-you-shouldnt-3d851d7f0b26). You will see more and more arrow functions as you progress deeper into JavaScript. Use the [stretch-function-conversion.js](assignments/stretch-function-conversion.js) file as a helper challenge to showcase some of the differences between ES5 and ES6 syntax. * Move on to tomorrow's content and start studying callbacks, write a few of your own to get the hang of it. * Look at array methods like .map(), .reduce(), .filter(). use them on the data in the arrays assignment to accomplish the same things you did with the ES5 for loop. diff --git a/assignments/arrays.js b/assignments/arrays.js index c007f3e99..a9f18be1d 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -63,34 +63,49 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year" // ==== Challenge 1 ==== // The dealer can't recall the information for a car with an id of 33 on his lot. Help the dealer find out which car has an id of 33 by logging the car's year, make, and model in the console log provided to you below: -console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*` ); +console.log(`Car 33 is a ${inventory[32].car_year} ${inventory[32].car_make} ${inventory[32].car_model}` ); // ==== Challenge 2 ==== // 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. -let lastCar = 0; -console.log(); +let lastCar = `${inventory[inventory.length-1].car_make} ${inventory[inventory.length-1].car_model}`; +console.log(`The last car in the inventory is a ${lastCar}`); // ==== Challenge 3 ==== // 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 let carModels = []; -console.log(); +for (let i=0; i