-
-
Notifications
You must be signed in to change notification settings - Fork 239
West Midlands | ITP-Sept-25 | Mustaf Asani | Sprint 2 | coursework/sprint-2 #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| function convertToPercentage(decimalNumber) { | ||
| const decimalNumber = 0.5; | ||
| //const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; | ||
| } | ||
|
|
||
| console.log(decimalNumber); |
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.
We could also move the declaration at line 10 outside the function without modifying the console.log statement.
Variables in different scopes can have the same name and the JS language has a set of rules to resolve "conflicting" names.
Do look up these two concepts, identifier scope and identifier resolution, in the context of JavaScript programming. ChatGPT can give a good explanation.
| } | ||
| // return the BMI of someone based off their weight and height | ||
| const bmi = weight / height ** 2; | ||
| return bmi.toFixed(1); |
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.
What type of value do you expect the function to return? A number or a string?
Does your function return the type of value you expect?
| function formatAs12HourClock(time) { | ||
| const hours = Number(time.slice(0, 2)); | ||
| const minutes = time.slice(3); | ||
| console.log(minutes); |
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.
Code submitted to a PR should be clean. So it is best practices to not leaving any debugging statement in the code.
|
|
||
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| return `${hours - 12}:${minutes} pm`; | ||
| } | ||
| return `${time} am`; | ||
| } |
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.
What do you expect from the following function calls?
formatAs12HourClock("00:00");
formatAs12HourClock("01:01");
formatAs12HourClock("13:01"); Does your function return the value you expected?
Learners, PR Template
Self checklist
Changelist
finished all the tasks for coursework sprint 2