Skip to content

Jasyn Marais - JavaScript I - 14 October 2019 - #2

Open
jasynmarais wants to merge 15 commits into
masterfrom
jasyn-marais-2
Open

jasynmarais wants to merge 15 commits into
masterfrom
jasyn-marais-2

Conversation

@jasynmarais

Copy link
Copy Markdown
Owner

No description provided.

@jasynmarais
jasynmarais requested a review from nedssoft October 14, 2019 15:16

@nedssoft nedssoft 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.

Good job on the project Jasyn, You started this unit in an impressive way. You may fix the suggested improvements and merge

Comment thread assignments/arrays.js
// 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("Arrays - Challenge 1:");
console.log(`Car 33 is a ${inventory[32].car_year} ${inventory[32].car_make} ${inventory[32].car_model}.`);

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 a good attempt. The downside is that it'll fail if the positions of the items in the array are changed. You could use the array method find or for loop to get the item whose id is 33, which would be a more stable solution.

Comment thread assignments/arrays.js
let lastCar = 0;
console.log();
console.log("Arrays - Challenge 2:");
let lastIndex = inventory.length-1; //declaring lastIndex as the last car in the inventory

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.

use const for a variable that does not change.

Comment on lines +8 to +11
let myFunction = () => {
console.log("Function was invoked!");
};
myFunction();

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.

use const for functions

// console.log(triple);

exampleArray = [1,2,3,4];
const triple = exampleArray.map(num => 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.

Nice! I like the arrow function and implicit return, this is a modern JS syntax.

Comment thread assignments/objects.js
Comment on lines +96 to +115
const parent = {
name: 'Susan',
age: 70,
speak() {
return `Hi, my name is ${this.name}`
},
child: {
name: 'George',
age: 50,
speak() {
return `Hi, my name is ${this.name}`
},
grandchild: {
name: 'Sam',
age: 30,
speak() {
return `Hi, my name is ${this.name}`
}
}
}

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.

Looks good!

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