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

Conversation

@malnaqeeb
Copy link

No description provided.

Copy link

@profxed profxed left a comment

Choose a reason for hiding this comment

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

Hello @malnaqeeb,

you have a good implementation of javascript, for the 3rd week, I will be asking changes since you have a syntax error in step2-3 and step2-2 can be improved a bit.

you have answered all questions, along side with the bonus.

since it's your third homework doing a PR, you submitted your 3rd on the same branch as the 1st and the 2nd, it's fine for this, but be sure to try to make it correct in the next times, because files get longer and harder to debug and read.

what I usually advice for submitting a homework is as:
https://gist.github.com/Meno-101/fed3a2f7988f6440fa57d02936bfdc70#file-readme-md

I have left few comments down below please have a look!

// What to do here?
// Replace this comment and the next line with your code
console.log(func);
// since we aim to pass bar as argument to foo then foo should return its parameter.
Copy link

Choose a reason for hiding this comment

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

To be accurate.

Suggested change
// since we aim to pass bar as argument to foo then foo should return its parameter.
// since we aim to pass bar as argument to foo then foo should call its parameter.

Copy link
Author

Choose a reason for hiding this comment

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

done 👍

threeCallback(elem);
} else if (elem % 5 === 0) {
fiveCallback(elem);
} else if (elem % 5 === 0 && elem % 3 === 0) {
Copy link

Choose a reason for hiding this comment

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

this condition will never be invoked, and that results with keeping number 15 with only a one call from the threeCallback,

perhaps removing the elses will solve the issue, and that will resolve the condition of:

if it's divisible by 3 and 5 do something
if it's divisible by 3 do another something
if it's divisible by 5 do other something

but for more simpler solution since we are calling functions only and not doing any kinda complex logic, it's simple as you can have two if statements as your condition 😁

Copy link
Author

Choose a reason for hiding this comment

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

done 👍

// Replace this comment and the next line with your code
console.log(str, num, result);
if (num <= 0){
return result;
Copy link

Choose a reason for hiding this comment

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

Oops! we have some syntax problems here 🤔
have you closed your if statement?

Copy link
Author

Choose a reason for hiding this comment

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

done 👍

}

// Use the Dog constructor above to create a new instance of Dog, assigning it to a variable hound.
const hound = new Dog();
Copy link

Choose a reason for hiding this comment

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

constructor functions used to be a way for creating objects in a more dynamic easy short way, yup all of these!

means if you have the same structure of data all time, as

{ name, age, favoritePlace, address1, address2, phoneNumber, mobileNumber, ...etc }

and they are with a different values each, imagine your self defining each of them in it's own line, as you are doing here on lines 4,5,6 , it's very short to have for a one user or two, but think of a million!

Instead of that we have constructors as:

function User(name, age, favoritePlace, address1, address2, phoneNumber, mobileNumber) {
  this.name = name;
  this.age = age;
  this.favoritePlace = favoritePlace;
  this.address1 = address1;
  // ...etc
}

// And. we can have them all defined in a one line,
// as for now, let's make it simple and hard code them as required in the homework
const me = new user('Jawhar', 23, 'Home', 'some where' /*, ...etc */);
console.log(me) // this will give us the previous object with the specified details I wrote up above.

Same applies to the Dog Object constructor.

Copy link
Author

Choose a reason for hiding this comment

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

ah, now i get what you mean. thanks 👍

// for unknown number of depths.
const arrXd = [[1, [2, 2, [3, [4, [5, [6]]]]], 1]];
function flattenWithXDimension(arr) {
return arr.flat(Infinity);
Copy link

Choose a reason for hiding this comment

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

Cool Stuff!

Copy link
Author

Choose a reason for hiding this comment

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

Thanks :)

// Add your explanation as a comment here
// y has reference type which is object, by default it pass by reference in function.
// because of that the reference can be assigned to anything else, it won’t affect the real object.
// But on the other hand, it also can be used to modify the original object
Copy link

Choose a reason for hiding this comment

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

💯

profxed
profxed previously approved these changes Sep 26, 2019
Copy link

@profxed profxed left a comment

Choose a reason for hiding this comment

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

Perfect thanks for the implementation, I have left a comment please have a look.

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