Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Hedyeh week 9 #1031

Open
wants to merge 8 commits into
base: manchester3
Choose a base branch
from
Open

Conversation

Hedyeh65
Copy link

Your Details

Your Name:
Your City:
Your Slack Name:

Homework Details

Module:
Week:

@@ -14,6 +14,7 @@ Take a look at the following code:
```

Explain why line 4 and line 6 output different numbers.
Because line 4 will print Local variable (which x is defined again) which is 2 but line 6 will print global variable which is 1
Copy link

Choose a reason for hiding this comment

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

Correct ✅

@@ -33,6 +34,7 @@ console.log(y)
```

What will be the output of this code. Explain your answer in 50 words or less.
line 32 print 10 and undefined because line 28 print 10 and y will return as undefined ,line 33 dosen't print anything because y is not defined globally.
Copy link

Choose a reason for hiding this comment

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

Line 32 will print undefined not because of y variable but because f1 function doesn't return anything. Line 33 will print a Reference Error because as you wrote, y not is defined globally

@@ -61,3 +63,4 @@ console.log(y);
```

What will be the output of this code. Explain your answer in 50 words or less.
9 and {x:10} because in line 50 it console.log (x) which is 9 and in line 60 it console.log(y) which is {x:9}
Copy link

Choose a reason for hiding this comment

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

Correct, and this is because f1 and f2 functions don't modify x and y variables in the global scope

return response.json();
})
.then((data) => {
console.log(data);
Copy link

Choose a reason for hiding this comment

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

Remember to delete console logs (line 12 and 22) before committing

setIcon(icon, document.querySelector(".icon"));

//change tempreture to celsius/farenheit
tempretureSection.addEventListener("click", () => {
Copy link

Choose a reason for hiding this comment

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

Well done! All works fine🙂 I would encourage you to always try to write a clean code - break the logic down into smaller functions and call them where needed.

if (amount > 0) {
this.balance += amount;
} else {
console.log(`Please enter a positive number`);
Copy link

Choose a reason for hiding this comment

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

I like the error handling here👏

console.log(`You have ${this.balance} in your account`);
}
make_withdrawl(amount) {
if (this.balance > amount && amount > 0) {
Copy link

Choose a reason for hiding this comment

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

Good error handling again - it shows that you think about what could go wrong

// Add your code here

constructor() {
this.i = 0;
Copy link

Choose a reason for hiding this comment

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

i could be something more meaningful here

}

shuffle() {
let random = Math.floor(Math.random() * this.playList.length);
Copy link

Choose a reason for hiding this comment

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

How would you make sure that the song won't be repeated when shuffle is called multiple times in a row?

this.i++;
this.play();
} else {
console.log(`There isn't any song to play`);
Copy link

Choose a reason for hiding this comment

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

I think it's fine to console log that there are no more songs to play, but another solution could be to start playing songs from the beginning

@Ashaghel Ashaghel added the reviewed A mentor has reviewed this PR label Jul 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
reviewed A mentor has reviewed this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants