Skip to content
This repository was archived by the owner on Aug 31, 2019. It is now read-only.

Advanced-JavaScript Completed - #39

Closed
JourdanClark wants to merge 2 commits into
bloominstituteoftechnology:masterfrom
JourdanClark:master
Closed

Advanced-JavaScript Completed#39
JourdanClark wants to merge 2 commits into
bloominstituteoftechnology:masterfrom
JourdanClark:master

Conversation

@JourdanClark

Copy link
Copy Markdown

No description provided.

…ng stuff being put into the array. Passed a index into sevel arrays.js methods cause I forgot to do that before.

@ryan-hamblin ryan-hamblin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well done. I'm really stoked about how far along you are. There are a lot of advanced concepts that you grasp really well. I only had a few critiques.

Comment thread notes/inheritance.js
this.name = name;
this.hitpoints = hitpoints;
this.level = level;
this.inventory = inventory || [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could potentially just default this in the constructor parens. constructor(inventory = [])
which would allow you to forego the ||.

Comment thread notes/inheritance.js
@@ -0,0 +1,135 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is really really fun! I'd like to rephrase something though. Objects in Javascript don't necessarily "Inherit" they way that you may be used to from other OO Languages. It's more that a "Parent" class would be "Delegating" do it's "Sub-classes". I'm sure you're aware of these intricacies, but I wanted to make it very clear Here is a link to a great article that talks about Prototypal 'inheritance' which really should say prototypal 'delegation'

Comment thread src/arrays.js
// Combine all elements into a single value going from left to right.
// Elements will be passed one by one into `cb`.
// `memo` is the starting value. If `memo` is undefined then make `elements[0]` the initial value.
if (typeof memo === 'undefined') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would be unnecessary as you have defaulted already in the function parens

Comment thread src/arrays.js
// Example: flatten([1, [2], [3, [[4]]]]); => [1, 2, 3, 4];
const array = [];
const cb = (item) => {
if (item instanceof Array) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice, instance of is great, you should look into Array.isArray()

Comment thread src/closure.js
// `cb` should only ever be invoked once for a given set of arguments.
const cache = {};
return (arg) => {
if (!(arg in cache)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

well done!

Comment thread src/objects.js
// Based on http://underscorejs.org/#keys

// not sure how to do this without just using an Object method
return arrayMethods.reduce(Object.entries(obj), (array, [key, value]) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

functional and shows you understand the concepts of the methods you've created already! Nice work!

Comment thread src/objects.js
// Like map for arrays, but for objects. Transform the value of each property in turn.
// http://underscorejs.org/#mapObject
const newObj = {};
for (let i = 0; i < keys(obj).length; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome. Passing your object back to your very one 'key' function. This is good stuff.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants