Skip to content
7 changes: 2 additions & 5 deletions Sprint-2/1-key-errors/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ console.log(decimalNumber);
// =============> write your new code here

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

return percentage;
}
return `${decimalNumber * 100}%`;
}
6 changes: 2 additions & 4 deletions Sprint-2/2-mandatory-debug/0.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
// =============> write your new code here

function product(a, b) {
const result = a * b;
console.log(result)
return result;
}
return a * b;
}
9 changes: 5 additions & 4 deletions Sprint-2/3-mandatory-implement/1-bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// It should return their Body Mass Index to 1 decimal place

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);
}
// return the BMI of someone based off their weight and height
const result = weight / Math.pow(height, 2);
const bmiString = result.toFixed(1);
return Number(bmiString);
}
9 changes: 2 additions & 7 deletions Sprint-2/3-mandatory-implement/2-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,5 @@
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase

function toUpperSnakeCase(string) {
let result = `${string}`
.split(" ")
.map(word => word.toUpperCase())
.reduce((accumulator, currentValue) => accumulator + "_" + currentValue);

return result;
}
return String(string).toUpperCase().replaceAll(" ", "_");
Copy link
Contributor

Choose a reason for hiding this comment

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

If string is already a string, we don't have to convert it to a string before using the string methods.

Copy link
Author

Choose a reason for hiding this comment

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

That's true but it didn't show up in the auto-complete, also given that JavaScript is a dynamically typed language without type safety, the parameter is any type, so I need to ensure that I am dealing with a String type otherwise it fails.

}
8 changes: 4 additions & 4 deletions Sprint-2/4-mandatory-interpret/time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ console.log(formatTimeDisplay(number));
// b) What is the value assigned to num when pad is called for the first time?
// =============> write your answer here

// 0
// "0"

// c) What is the return value of pad is called for the first time?
// =============> write your answer here

// 00
// "00"

// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here

// 1
// "1"

// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here

// 01
// "01"
2 changes: 1 addition & 1 deletion Sprint-2/5-stretch-extend/format-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

function formatAs12HourClock(time) {
let hours = Number(time.slice(0, 2));
const minutes = time.slice(3, 5);
const minutes = time.slice(-2);

if (hours === 24) {
hours = 0;
Expand Down