Skip to content

Jonathan Holloway - #152

Open
codejoncode wants to merge 5 commits into
bloominstituteoftechnology:masterfrom
codejoncode:master
Open

Jonathan Holloway#152
codejoncode wants to merge 5 commits into
bloominstituteoftechnology:masterfrom
codejoncode:master

Conversation

@codejoncode

Copy link
Copy Markdown

completed arrays.js

Comment thread assignments/arrays.js
// ==== 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*` );
for(car in inventory){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cool use of a for in loop. Did we need it though?
console.log(`Car 33 is a ${inventory[32].car_year} ${inventory[32].car_make} ${inventory[32].car_model})
This solution uses template literals which I don't think was covered in the lecture so if you don't necessary understand what this is doing shoot me a DM. They just allow us to directly access/reference properties within the object using a specific syntax.

Comment thread assignments/arrays.js
let lastCar = 0;
console.log();
let lastCar = inventory.length;
for(car in inventory){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar to your first solution this definitely gets it done but you could have done it in a simpler way.

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

No need to loop and create extra run time.

Comment thread assignments/arrays.js
// 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 (car in inventory){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Based on the repeated use of for in I am gonna assume that you know how to write a basic for loop however I would have liked you to have written it out once. For in has some use cases where it will not work and you are going to have to use a basic loop. Also am not sure it was necessary to use toLowerCase(). Maybe you could convince me if we actually discussed it 😃

Comment thread assignments/objects.js
@@ -50,15 +89,30 @@ let example = {
// 4. Give each of the objects the ability to speak their names using the this keyword.

let parent = {}

@Nate152 Nate152 Jun 26, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We wanted to see you create a nested object here. Example:

let parent = {
  "name": "Susan",
  "age": 70,
  "speak": function() {
    return "My name is: " + this.name; 
  },
  "child": {
    "name": "George",
    "age": 50,
    "speak": function() {
      return "My name is: " + this.name; 
    },
    "grandchild": {
      "name": "Sam",
      "age": 30,
      "speak": function() {
        return "My name is: " + this.name; 
      }
    }
  }
}

And then based on this nesting structure:

// Log the parent object's name
console.log(parent.name);
// Log the child's age
console.log(parent.child.name)
// Log the name and age of the grandchild
console.log(parent.child.grandchild.name, parent.child.grandchild.age)
// Have the parent speak
console.log(parent.speak());
// Have the child speak
console.log(parent.child.speak());
// Have the grandchild speak
console.log(parent.child.grandchild.speak());

@Nate152

Nate152 commented Jun 26, 2018

Copy link
Copy Markdown

Check out my comments and make sure you don't have any questions. You are using some more advanced JS techniques so my assumption is that you understand the basics. JS can be approached in a ton of different ways and none of your solutions are wrong by any means but there are some specific concepts that were trying to have you show and thats what my comments pertain to.

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