Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sprint-2/1-key-errors/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ console.log(decimalNumber);
// =============> write your new code here

function convertToPercentage(decimalNumber) {
decimalNumber = 0.5;
const percentage = `${decimalNumber * 100}%`;

console.log(decimalNumber);
Copy link
Contributor

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.

return percentage;
}

convertToPercentage(54);


3 changes: 2 additions & 1 deletion Sprint-2/3-mandatory-implement/1-bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

function calculateBMI(weight, height) {
let BMI = weight/(height*height);
return BMI.toFixed(1);
return Math.round(BMI * 100) / 100;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 100)


// 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));
2 changes: 1 addition & 1 deletion Sprint-2/4-mandatory-interpret/time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

num here refer to the parameter of pad(). When pad() is called the first time, the parameter passed to the function is not 61.


// c) What is the return value of pad is called for the first time?
// =============> write your answer here: '00' - string of full hours
Expand Down
6 changes: 4 additions & 2 deletions Sprint-2/5-stretch-extend/format-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down Expand Up @@ -44,15 +46,15 @@ console.assert(

// hours = 00 and minutes = 00
const currentOutput5 = formatAs12HourClock("00:00");
Copy link
Contributor

Choose a reason for hiding this comment

The 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";
Copy link
Contributor

Choose a reason for hiding this comment

The 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}`
Expand Down