Skip to content

Commit 5adb1fc

Browse files
Aplly all changes asked by the reviewer
1 parent b5dc2cf commit 5adb1fc

5 files changed

Lines changed: 10 additions & 13 deletions

File tree

Sprint-2/1-key-errors/1.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
// Predict and explain first...
22

33
// Why will an error occur when this program runs?
4-
// =============> Instead of calling the function, a variable is called
4+
// =============> Line 9 the variable "decimalNumber" is declared as a parameter passed to the function
5+
// but again on line 10 inside the function, the variable is declared
56

67
// Try playing computer with the example to work out what is going on
78

9+
const decimalNumber = 0.5;
810
function convertToPercentage(decimalNumber) {
9-
const decimalNumber = 0.5;
1011
const percentage = `${decimalNumber * 100}%`;
1112

1213
return percentage;
1314
}
1415

15-
console.log(decimalNumber);
16-
17-
// =============> Also inside the function, decimalNumber is called again
16+
console.log(convertToPercentage(decimalNumber));
1817

1918
// Finally, correct the code to fix the problem
2019
// =============> decimalNumber = 0.5;

Sprint-2/1-key-errors/2.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
21
// Predict and explain first BEFORE you run any code...
32

43
// this function should square any number but instead we're going to get an error
54

65
// =============> The variable num is not declared
76

8-
function square(3) {
9-
return num * num;
7+
function square(num) {
8+
return num * num;
109
}
10+
console.log(square(3));
1111

1212
// =============>SyntaxError: Unexpected number
1313

@@ -16,5 +16,3 @@ function square(3) {
1616
// Finally, correct the code to fix the problem
1717

1818
// =============> function square(num) {
19-
20-

Sprint-2/3-mandatory-implement/1-bmi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
1919
const bmi = weight / height ** 2;
20-
return bmi.toFixed(1);
20+
return parseFloat(bmi.toFixed(1));
2121
}
2222
console.log(calculateBMI(70, 1.73));

Sprint-2/3-mandatory-implement/2-cases.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
// Use the MDN string documentation to help you find a solution
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
1717
function makeUpperSnakeCase(str) {
18-
return str.toUpperCase().split(" ").join("_");
18+
return str.toUpperCase().replaceAll(" ", "_");
1919
}

Sprint-2/5-stretch-extend/format-time.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
function formatAs12HourClock(time) {
66
const hours = Number(time.slice(0, 2));
7-
const minutes = time.slice(3);
7+
const minutes = time.slice(-2);
88
if (hours === 0) return `12:${minutes} am`;
99
else if (hours === 12) return `12:${minutes} pm`;
1010
else if (hours > 12) {

0 commit comments

Comments
 (0)