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

Solutions for Advanced-JavaScript - #55

Closed
bluebackground wants to merge 4 commits into
bloominstituteoftechnology:masterfrom
bluebackground:master
Closed

bluebackground wants to merge 4 commits into
bloominstituteoftechnology:masterfrom
bluebackground:master

Conversation

@bluebackground

Copy link
Copy Markdown

First set of complete answers.

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

Overall things are looking pretty good. I would suggest coming back and plowing through the extra credit. Also there are many line breaks where there don't need to be, and as for me, (this being a stylistic preference) I would return the PR and ask you to fix those line breaks. But that's not the case for everyone's style. Overall you're doing great. Keep it up. Keep plowing through the complicated stuff! It's not easy!

Comment thread src/arrays.js
// declare result array object to be returned.
const result = [];
// loop over the elements
for (let i = 0; i < elements.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.

You're good to reuse your .each() method here. Maybe you could give it a try.

Comment thread src/arrays.js
};
let result = [];

function getValues(element, res = []) {

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 default in the parens.

Comment thread src/arrays.js
return res;
}

for (let i = 0; i < elements.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.

Not sure what's going on with two different loops here. There may be a better way to solve this. Please refer to the video posted about flatten and reduce, it's up in Week 1 on your piazza account.

Comment thread src/class.js
// `meow` that should return the string `<name> meowed!` where `<name>` is the `name`
// property set on the Cat instance.

class User {

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 all looks really good. It seems like you have a good grasp on these concepts here.

Comment thread src/closure.js

return (...val) => {
count++;

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.

No need for this space right here.

Comment thread src/closure.js
const result = [];
return (unknown) => {
if (arg.indexOf(unknown) !== -1) {
return result[arg.indexOf(unknown)];

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 work. I really like indexOf. And I like that you used an array to cache your function call. I would rename this array to something more descriptive other than 'arg' just to make sure if someone was to re-read your code, they'd be able to understand exactly what 'arg' is.

Comment thread src/objects.js
return result.push(obj[k]);
});

// for (const key in obj) {

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 can just deleted code that you've commented out. It makes for a cleaner submission.

Comment thread src/objects.js
// Return `obj`.
// http://underscorejs.org/#defaults
function hasKey(o, ky) {
// const objKeys = Object.keys(o);

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.

please remove this commented out code

Comment thread src/recursion.js
const nFibonacci = (n) => {
// fibonacci sequence: 1 2 3 5 8 13 ...
// return the nth number in the sequence
if (n < 0) {

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.

I think you can simplify all of this logic to one single line. if (n <= 2) return n

Comment thread src/recursion.js
});
// console.log(`Check: No object found in values. (@ depth level:${level})`);
return true;
// ~~~~~~~~WHYYY!!!!!! Does this happen!!!!!!~~~~~

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're going to be receiving this as a toy problem today. You should be able to think through it. Otherwise you'll have some exposure to it and you'll be able to come back and nail it!

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