Skip to content

5-6-19 Javascript Project - #1

Open
Zolton wants to merge 4 commits into
masterfrom
greg-zolton
Open

5-6-19 Javascript Project#1
Zolton wants to merge 4 commits into
masterfrom
greg-zolton

Conversation

@Zolton

@Zolton Zolton commented May 6, 2019

Copy link
Copy Markdown
Owner

Finished Object.js and function-conversion.js, as well as stretch goals for both.

Not going to do array.js. It's an obvious oversight that it was included, and I'm already furious that I wasted an hour and a half of my time on it. The other two exercises, object.js and functions.js were quite good, and helped deepen my understanding of the material, but array.js was like asking a preschooler to perform physics.

@Zolton
Zolton requested a review from OmarSalah95 May 6, 2019 21:43
…it. Half an hour of the zoom session and explaining how to use a for-loop, and I knocked out challenges 3, 4, 5, and 6 in less than 30 minutes

@OmarSalah95 OmarSalah95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job reaching into stretch here Greg! I can see after our short review you seem to have a much better grasp of the base concepts of how things are working which is great! keep up the great work!

Comment thread assignments/arrays.js
//the car's year, make, and model in the console log provided to you below:


console.log("Car 33 is a " + inventory[32].car_model + " made by " + inventory[32].car_make + " and the year is " + inventory[32].car_year);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard coding which car and position in the array you are pointing at and it is a no-no. What if the position of that care shifted because another car has been sold?

What you want to do is iterate through each item in the array testing the id key on each object as you do, IF the id matches then you want to return that data.

Comment thread assignments/arrays.js
//What is the make and model of the last car in the inventory? Log the make and model into the console.

let lastCar = inventory.length - 1;
console.log(inventory[lastCar]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of .length reduced by one to target the last item, since arrays start at 0 index and not 1

Comment thread assignments/arrays.js
newArray.push(inventory[i].car_model)
}

console.log(newArray.sort());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job breaking this into 2 pieces and just adding the sort to the newArray. I would take another look at more specific naming convention here though. This way it doesn't become confusing.

Comment thread assignments/arrays.js

let oldCars = [];
console.log();
console.log(carYears[5])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Comment thread assignments/arrays.js

if (inventory[i].car_make === "BMW" || inventory[i].car_make === "Audi")

BMWAndAudi.push(inventory[i])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of the or Logical Operator || here.

Don't forget to open and close {} after your IF conditional. Inside of that block of code is what will be executed if the if conditions are met.

// console.log(triple);

let triple = exampleArray.map((num) => {return num * 3;});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job solving this one with .map. since you are using fat arrow syntax you actually don't need the brackets or the return. Fat arrow functions have what is called an implicit return. You could write the map as such

.map((num) => num * 3);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants