-
-
Notifications
You must be signed in to change notification settings - Fork 239
London | 25-ITP-September | Ammad Ur Rehman | Sprint 2 | 03 Complete Sprint 2 Coursework #786
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 percentaged(decimalNumber) { | ||
| const constant = 0.5; | ||
| const percentage = `${constant * 100}%`; | ||
|
|
||
| return percentage; | ||
| } |
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 function would always return "50%" regardless of the parameter value.
|
|
||
| function product(a, b) { | ||
| const result = a * b; | ||
| console.log(result) |
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.
It is a best practice to remove all debugging code before submitting our code for review.
| function calculateBMI(weight, height) { | ||
| // return the BMI of someone based off their weight and height | ||
| const result = weight / Math.pow(height, 2); | ||
| return result.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?
| .split(" ") | ||
| .map(word => word.toUpperCase()) | ||
| .reduce((accumulator, currentValue) => accumulator + "_" + currentValue); |
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.
Why not use the built-in String function to replace characters?
| // c) What is the return value of pad is called for the first time? | ||
| // =============> write your answer here | ||
|
|
||
| // 00 |
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.
A common convention for indicating that a value is a string is to enclose it in double quotes. For example, "00".
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| let hours = Number(time.slice(0, 2)); | ||
| const minutes = time.slice(3, 5); |
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 can also extract the last two characters as time.slice(-2).
Learners, PR Template
Self checklist
Changelist
I completed all the exercises.
Questions
I understand why TypeScript exists. JavaScript should have been a statically typed language.