Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9c56524
add explanation for line 3
LiyemaMfengwana Jun 15, 2026
258c544
add solution to initials,js
LiyemaMfengwana Jun 15, 2026
bb5f2a0
add solution to paths.js
LiyemaMfengwana Jun 15, 2026
cb97a28
add explanation and breaking down random.js
LiyemaMfengwana Jun 15, 2026
82ee28e
fix error multi line commenting
LiyemaMfengwana Jun 15, 2026
66b60ba
fix error by changing const to let
LiyemaMfengwana Jun 15, 2026
3d99c5d
fix error : declare constant first
LiyemaMfengwana Jun 15, 2026
cc3622b
explain and fix error 3
LiyemaMfengwana Jun 15, 2026
e526960
fix invalid variable name
LiyemaMfengwana Jun 15, 2026
8b6c551
debugging errors
LiyemaMfengwana Jun 15, 2026
40e7f61
answer questions
LiyemaMfengwana Jun 15, 2026
6b61878
breakdown of each line
LiyemaMfengwana Jun 15, 2026
0150260
add console log
LiyemaMfengwana Jun 19, 2026
ee92c6c
add console log
LiyemaMfengwana Jun 19, 2026
d3c7750
add more functions
LiyemaMfengwana Jun 19, 2026
e5de512
declare variables
LiyemaMfengwana Jun 22, 2026
0763056
deugging
LiyemaMfengwana Jun 22, 2026
ee94a45
fix: correct capitalise function
LiyemaMfengwana Jun 23, 2026
a6ba68a
fix: correct convertToPercentage function
LiyemaMfengwana Jun 23, 2026
0a05291
fix: repair square function bug
LiyemaMfengwana Jun 23, 2026
36a44d5
fix: return value from multiply instead of logging to fix undefined o…
LiyemaMfengwana Jun 23, 2026
06a880c
fix: remove early return and return sum correctly
LiyemaMfengwana Jun 23, 2026
2c1769a
fix: use function parameter instead of global variable in getLastDigit
LiyemaMfengwana Jun 23, 2026
2c5e84b
implement BMI function
LiyemaMfengwana Jun 23, 2026
a76bb45
feat: convert string to UPPER_SNAKE_CASE using split, map, and join
LiyemaMfengwana Jun 23, 2026
6ed6522
feat: convert toPounds script into reusable function and add test cases
LiyemaMfengwana Jun 23, 2026
04c466b
interpret code
LiyemaMfengwana Jun 23, 2026
e00d0c1
Remove Sprint-1 from PR
LiyemaMfengwana Jun 23, 2026
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
6 changes: 0 additions & 6 deletions Sprint-1/1-key-exercises/1-count.js

This file was deleted.

11 changes: 0 additions & 11 deletions Sprint-1/1-key-exercises/2-initials.js

This file was deleted.

23 changes: 0 additions & 23 deletions Sprint-1/1-key-exercises/3-paths.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sprint-1/1-key-exercises/4-random.js

This file was deleted.

2 changes: 0 additions & 2 deletions Sprint-1/2-mandatory-errors/0.js

This file was deleted.

4 changes: 0 additions & 4 deletions Sprint-1/2-mandatory-errors/1.js

This file was deleted.

5 changes: 0 additions & 5 deletions Sprint-1/2-mandatory-errors/2.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sprint-1/2-mandatory-errors/3.js

This file was deleted.

2 changes: 0 additions & 2 deletions Sprint-1/2-mandatory-errors/4.js

This file was deleted.

22 changes: 0 additions & 22 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js

This file was deleted.

25 changes: 0 additions & 25 deletions Sprint-1/3-mandatory-interpret/2-time-format.js

This file was deleted.

27 changes: 0 additions & 27 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js

This file was deleted.

18 changes: 0 additions & 18 deletions Sprint-1/4-stretch-explore/chrome.md

This file was deleted.

16 changes: 0 additions & 16 deletions Sprint-1/4-stretch-explore/objects.md

This file was deleted.

35 changes: 0 additions & 35 deletions Sprint-1/readme.md

This file was deleted.

12 changes: 11 additions & 1 deletion Sprint-2/1-key-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
// Predict and explain first...
// =============> write your prediction here
// =============> It should take a string and capitalise the first letter but i predict it will throw an

// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring

/*The error occurs because str is declared twice. The function already receives str as a parameter, and then let str tries to create another variable with the same name inside the same scope. JavaScript does not allow redeclaring a variable with let, so it throws an error.*/

function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
}

// =============> write your explanation here

/* This function takes a string and capitalise the first letter. It uses `str[0].toUpperCase()` to convert the first character to uppercase and `str.slice(1)` to get the rest of the word unchanged. The function then joins both parts together and returns the new string. When `console.log(capitalise("hello"), capitalise("world"))` is run, the function executes twice and prints `Hello World`.
*/

// =============> write your new code here
function capitalise(str) {
return (str = `${str[0].toUpperCase()}${str.slice(1)}`);
}
console.log(capitalise("hello"), capitalise("world"));
11 changes: 10 additions & 1 deletion Sprint-2/1-key-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Predict and explain first...

// Why will an error occur when this program runs?
// =============> write your prediction here

Expand All @@ -16,5 +15,15 @@ console.log(decimalNumber);

// =============> write your explanation here

/*An error will occur when the program runs because decimalNumber is declared twice. The function already receives decimalNumber as a parameter, but then const decimalNumber = 0.5 tries to create another variable with the same name inside the same scope. JavaScript does not allow redeclaring variables with const.
Another error will happen at console.log(decimalNumber) because decimalNumber only exists inside the function and cannot be accessed outside of it.*/

// Finally, correct the code to fix the problem
// =============> write your new code here
function convertToPercentage(decimalNumber) {
const percentage = `${decimalNumber * 100}%`;

return percentage;
}

console.log(convertToPercentage(0.5));
7 changes: 7 additions & 0 deletions Sprint-2/1-key-errors/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
// this function should square any number but instead we're going to get an error

// =============> write your prediction of the error here
/*An error will occur because a number was used as a function parameter instead of a variable name.*/

function square(3) {
return num * num;
}

// =============> write the error message here
//SyntaxError: Unexpected number

// =============> explain this error message here
/*The error happens because JavaScript expects a variable name inside the function brackets, but it found a number instead.*/

// Finally, correct the code to fix the problem

// =============> write your new code here

function square(num) {
return num * num
}
console.log(square(3));

8 changes: 8 additions & 0 deletions Sprint-2/2-mandatory-debug/0.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Predict and explain first...

// =============> write your prediction here
/*The code will print a correct multiplication inside the function*/

function multiply(a, b) {
console.log(a * b);
Expand All @@ -9,6 +10,13 @@ function multiply(a, b) {
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

// =============> write your explanation here
/*The result shows undefined because the function prints the answer with console.log instead of returning it, so nothing is passed back into the template string.*/

// Finally, correct the code to fix the problem
// =============> write your new code here

function multiply(a, b) {
return a * b;
}

console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
11 changes: 10 additions & 1 deletion Sprint-2/2-mandatory-debug/1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Predict and explain first...
// =============> write your prediction here

//The sum of 10 and 32 is undefined
function sum(a, b) {
return;
a + b;
Expand All @@ -9,5 +9,14 @@ function sum(a, b) {
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

// =============> write your explanation here

/*The function returns undefined because the return; statement ends the function immediately, so the calculation a + b never runs or gets returned.*/

// Finally, correct the code to fix the problem
// =============> write your new code here

function sum(a, b) {
return a + b;
}

console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
23 changes: 23 additions & 0 deletions Sprint-2/2-mandatory-debug/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

// Predict the output of the following code:
// =============> Write your prediction here
/*The output will be:

The last digit of 42 is 3
The last digit of 105 is 3
The last digit of 806 is 3*/

const num = 103;

Expand All @@ -15,10 +20,28 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);

// Now run the code and compare the output to your prediction
// =============> write the output here

/*The last digit of 42 is 3
The last digit of 105 is 3
The last digit of 806 is 3*/

// Explain why the output is the way it is
// =============> write your explanation here

/*The function always returns the last digit of 103 because it ignores the input parameter and uses a fixed global variable instead of the number passed into it.*/

// Finally, correct the code to fix the problem
// =============> write your new code here

function getLastDigit(number) {
return number.toString().slice(-1);
}

console.log(`The last digit of 42 is ${getLastDigit(42)}`);
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
console.log(`The last digit of 806 is ${getLastDigit(806)}`);

// This program should tell the user the last digit of each number.
// Explain why getLastDigit is not working properly - correct the problem

/*The function is not working properly because it ignores the input values and always uses the global variable num (which is 103), so every result returns the last digit of 103 instead of the number passed into the function.*/
6 changes: 4 additions & 2 deletions Sprint-2/3-mandatory-implement/1-bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
// 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 bmi = weight / (height * height);
return Number(bmi.toFixed(1)); // return the BMI of someone based off their weight and height
}
console.log(calculateBMI(80, 1.73));
Loading