-
-
Notifications
You must be signed in to change notification settings - Fork 195
ITP_GLASGOW_MAR | HANNA_MYKYTIUK | MODULE_STRUCTURING_AND_TESTING_DATA | SPRINT_2 #441
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?
Changes from 1 commit
f4e9c6b
6c4cfde
980fac0
3ee1a41
eba5d0c
5de2a8e
06bd8cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,9 @@ | |
|
||
function calculateBMI(weight, height) { | ||
let BMI = weight/(height*height); | ||
return BMI.toFixed(1); | ||
return Math.round(BMI * 100) / 100; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach works but it would round the number to two decimal place (because of |
||
|
||
// return the BMI of someone based off their weight and height | ||
// yes it better to be number in case we want to use it in some other calculations | ||
} | ||
console.log(calculateBMI(62.99,1.64)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ console.log(formatTimeDisplay(61)); | |
// Call formatTimeDisplay with an input of 61, now answer the following: | ||
|
||
// b) What is the value assigned to num when pad is called for the first time? | ||
// =============> write your answer here: 00:01:01 | ||
// =============> write your answer here: 61 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// c) What is the return value of pad is called for the first time? | ||
// =============> write your answer here: '00' - string of full hours | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ function formatAs12HourClock(time) { | |
const minutes = time.slice(-2); | ||
if (hours > 12) { | ||
return `${hours - 12}:${minutes} pm`; | ||
} else if ( hours == 0 ){ | ||
return `12:${minutes} am`; | ||
} | ||
return `${time} am`; | ||
} | ||
|
@@ -44,15 +46,15 @@ console.assert( | |
|
||
// hours = 00 and minutes = 00 | ||
const currentOutput5 = formatAs12HourClock("00:00"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "00:00" should be converted to "12:00 am" (midnight). |
||
const targetOutput5 = "00:00 am"; | ||
const targetOutput5 = "12:00 am"; | ||
console.assert( | ||
currentOutput5 === targetOutput5, | ||
`current output: ${currentOutput5}, target output: ${targetOutput5}` | ||
); | ||
|
||
// hours = 12 and minutes = 00 | ||
const currentOutput6 = formatAs12HourClock("12:00"); | ||
const targetOutput6 = "00:00 pm"; | ||
const targetOutput6 = "12:00 pm"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does your function return this expected value? |
||
console.assert( | ||
currentOutput5 === targetOutput5, | ||
`current output: ${currentOutput5}, target output: ${targetOutput5}` | ||
|
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 think the function is expected to compute and return a percentage string when given a number; it should not output
0.5
every time the function is called.If we want to output 0.25 as 25%, we could write
console.log( convertToPercentage(0.25) );
outside the function.