Andrew Ghobrial - JavaScript-I#179
Andrew Ghobrial - JavaScript-I#179ghobs91 wants to merge 6 commits intobloominstituteoftechnology:masterfrom
Conversation
|
Thank you for your PR. |
gooseandmegander
left a comment
There was a problem hiding this comment.
Nice work, Andrew. I've left a few comments for you to review. If you have time, go for the stretch.
| 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); |
There was a problem hiding this comment.
Nicely done. Look into template literals for fun: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
| console.log('==== Challenge 2 ===='); | ||
| // ==== 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; |
There was a problem hiding this comment.
On the next line, where you are using inventory[lastCar].car_make and inventory[lastCar].car_model, you're actually grabbing the first car in the list rather than the last. What can you do to let lastCar = 0 to get it to grab the last car in the array?
| console.log(); | ||
|
|
||
| let carModels = []; | ||
| for (i = 0; i < inventory.length; i++) { |
There was a problem hiding this comment.
Don't forget the let in the for loop: for (let i = 0 ...) { ... }. Why is the let necessary?
| for (i = 0; i < inventory.length; i++) { | ||
| carModels.push(inventory[i].car_model); | ||
| } | ||
| carModels.sort(); |
There was a problem hiding this comment.
You can also move the carModels.sort() into the next line like: console.log('Car models alphabetically: ', carModels.sort());
| for (i = 0; i < inventory.length; i++) { | ||
| carYears.push(inventory[i].car_year); | ||
| } | ||
| console.log('list of car years: ' + carYears); |
| } | ||
| } | ||
|
|
||
| let BMWAndAudiStringified = JSON.stringify(BMWAndAudi); |
| // Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint. | ||
| // console.log(kennan.speak()); | ||
|
|
||
| const kennanGreeting = 'Hello, my name is ' + intern1.name + '!'; |
There was a problem hiding this comment.
Here you are declaring a variable and logging out the variable. You need to add the speak method to the intern1 object. How do you add a method to an object after the object has already been declared?
| // Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint. | ||
| //console.log(antonietta.multiplyNums(3,4)); | ||
|
|
||
| function multiplyNums (x, y) { |
There was a problem hiding this comment.
The same for this exercise as the one above. You aren't adding multiplyNums to Antonietta's object. In the console.log where antonietta.multiplyNums... is, that is the hint showing multiplyNums should be attached to the antonietta object.
@gooseandmegander