Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

My homework Week3 #199

Closed
wants to merge 3 commits into from
Closed

My homework Week3 #199

wants to merge 3 commits into from

Conversation

Kani103
Copy link

@Kani103 Kani103 commented Dec 2, 2018

i did some steps, the other steps still working on it. sorry!!

Copy link

@rohni rohni left a comment

Choose a reason for hiding this comment

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

Hey there,
A good effort, although I am missing:

  • 2-step3.js
  • 6-step3.js
  • 7-step3.js
  • step4.js
    which is quite a lot of the homework.
    I would look at the feedback as it seems you are missing some of the concepts these exercises are mean't to illustrate.
    Best of luck with the rest of the course. 😄

@@ -2,6 +2,7 @@

function foo(func) {
// What to do here?
return func
}
Copy link

Choose a reason for hiding this comment

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

Not quite. All you will do here is return the function object. You want to call func and return the value from calling func.

....
return func();
....

@@ -3,23 +3,38 @@
// use a 'for' loop
Copy link

Choose a reason for hiding this comment

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

Where did 2-step3.js go to?

}

console.log('for', repeatStringNumTimesWithFor('abc', 3));

// use a 'while' loop
function repeatStringNumTimesWithWhile(str, num) {
// add your code here
return str;
while (num > 0) {
Copy link

Choose a reason for hiding this comment

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

You have to define string before you can use it.
This is where your program errors out because it cannot find string.
It is very obvious that you have not run or tested your program, otherwise you would have seen the error message, and been able to correct the problem which is:

let string = '';

this.name = "Jumbo";
this.color = "Black";
this.numLegs = 4;
}
Copy link

Choose a reason for hiding this comment

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

Correct. ✅
Just wondering why you removed the line that actually creates an instance of a Dog.

this.color = "brown";
this.numLegs = 4;
}
// Add your code below this line
Copy link

Choose a reason for hiding this comment

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

This question was about nested loops, no the Dog.

@@ -3,8 +3,14 @@
const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
Copy link

Choose a reason for hiding this comment

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

I seem to be missing, 6-step3.js, 7-step3.js, and step4.js.

function removeDoubles(foo) {
const uniqueLetters = [];
for (let i = 0; i < foo.length; i++){
uniqueLetters.push(foo[i]);
Copy link

Choose a reason for hiding this comment

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

All you are doing here is copying the whole array. Not removing the duplicate values.
You need to check first whether the value already exists in uniqueLetters and if it does just skip to the next iteration of the loop, and if it does not, add it to uniqueLetters.

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

Successfully merging this pull request may close these issues.

4 participants