-
-
Notifications
You must be signed in to change notification settings - Fork 437
Glasgow 6 - Hussein Al-Sayed - JS - week 2 #446
base: main
Are you sure you want to change the base?
Conversation
*/ | ||
|
||
function getMood() { | ||
function getMood(isHappy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while you realized that you need to add the isHappy as a parameter there is still the case of variable shadowing that blocks this function to behave properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still trying to understand these differences and their behaviour. however i believe i fixed it now 👍
mandatory/1-fix-functions.js
Outdated
|
||
function greaterThan10(num) { | ||
let isBigEnough; | ||
let isBigEnough = Number > 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea is good, however care must be taken to make sure variable names that mean the same value are named exactly the same throughout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, fixed now 👍
mandatory/2-function-creation.js
Outdated
function applyDiscount(totalPrice) {} | ||
function applyDiscount(totalPrice) { | ||
if (totalPrice > 200) { | ||
return totalPrice * 0.9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having proper indenting inside functions and blocks is usually a good way to make sure code is readable. You should make sure to use an editor that has auto-indenting enabled as that helps making sure everything is in order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm using vsc, is there any extensions i can use for this?
mandatory/2-function-creation.js
Outdated
} else if (price2 > price1) { | ||
return price2; | ||
} else { | ||
return price1||price2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the price is the same then you can simply return whicever value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true! I thought this way i'd be showing that i'm aware there's no difference. but i guess code length and simplicity matters more.. edited now 👍
mandatory/2-function-creation.js
Outdated
*/ | ||
function canRegister(age) {} | ||
function canRegister(age) { | ||
if (age < 13) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer using <=
and >=
in case the text is defined that way to avoid differences between the specification and the solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, thank you
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.md
in the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?