Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
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.

15 changes: 11 additions & 4 deletions Sprint-2/1-key-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Predict and explain first...
// =============> write your prediction here

// =============> I presume the str is repeatedly declared, first as a parameter and again as a variable.
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring

Expand All @@ -9,5 +8,13 @@ function capitalise(str) {
return str;
}

// =============> write your explanation here
// =============> write your new code here
// =============> str is already declared in the parameter and shouldn't be declared inside the function. The error says it's been declared already for this reason. Therefore we need to rename the str inside the function.
/* ==========> function capitalise(str) {
let result = `${str[0].toUpperCase()}${str.slice(1)};
return result;
}
OR
function capitalise(str) {
return `${str[0].toUpperCase()}${str.slice(1)}`;
}
*/
15 changes: 11 additions & 4 deletions Sprint-2/1-key-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Predict and explain first...

// Why will an error occur when this program runs?
// =============> write your prediction here
// =============> The error will appear because we are trying to log the variable decimalNumber in the function. We have to call the function at this point. Besides to that, the decimalNumber is again declared inside the function where it shouldn't be.

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

Expand All @@ -14,7 +13,15 @@ function convertToPercentage(decimalNumber) {

console.log(decimalNumber);

// =============> write your explanation here
// =============> it says decimalNumber has aleady been declared for the above reason.

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

return percentage;
}
const result = convertToPercentage();
console.log(result);
*/
14 changes: 7 additions & 7 deletions Sprint-2/1-key-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@

// Predict and explain first BEFORE you run any code...

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

// =============> write your prediction of the error here
// =============> It is going to throw an error message as 3 is written in incorrect position. That position is set only for parameters, not arguments.

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

// =============> write the error message here
// =============> in the node repl, it says unexpected number, as the function always expects a parameter to be declared in its definition.

// =============> explain this error message here
// =============> The error is already described above.

// Finally, correct the code to fix the problem

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


/* ===========> function square(num) {
return num * num;
}
*/
7 changes: 5 additions & 2 deletions Sprint-2/2-mandatory-debug/0.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ function multiply(a, b) {

console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

// =============> write your explanation here
// =============> The function is only printing values on the console but not returning the value to the caller. Henceforth, it outputs both 320 and undefined on the console. 320 is the result of the console.log(a * b) inside the function, whereas undefined comes from the outer console.log(...) as it tries to bring forth and print the result of the function multiply(a, b). But the function is not returning any value and hence undefined appears on the console.

// 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)}`);
13 changes: 8 additions & 5 deletions Sprint-2/2-mandatory-debug/1.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Predict and explain first...
// =============> write your prediction here
// =============> As the function is not retuning anything, we're going to see undefined on the console.

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

console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

// =============> write your explanation here
// =============> The function uses parameters a and b. It calculates the addition of a and b. Supposedly it should return the result and then we can use the value of the function, but it is returning nothing at all as return is closed without being specified.
// 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 ${(10, 32)}`);
*/
16 changes: 11 additions & 5 deletions Sprint-2/2-mandatory-debug/2.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
// Predict and explain first...

// Predict the output of the following code:
// =============> Write your prediction here
// =============> the function is going to return error as the /1 is not valid expression or syntax

const num = 103;

function getLastDigit() {
function getLastDigit(num) {
return num.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)}`);
console.log(`The last digit of 7247 is ${getLastDigit(7274)}`);

// Now run the code and compare the output to your prediction
// =============> write the output here
/* ===========> function getLastDigit() {
return num.toString().slice(-1);
*/
// Explain why the output is the way it is
// =============> write your explanation here
// =============> this is because the /1 is not defined and not valid in the system of javaScript languague, so it throws an error. Morever because the parameter for the function is not defined, the function takes the global variable scope to run the code inside it. So obviously, we need to put down a parameter which is num to have the function work for any number other than the global variable scope.
// Finally, correct the code to fix the problem
// =============> write your new code here
/* ============> function getLastDigit(num) {
return num.toString().slice(-1);
}
*/

// This program should tell the user the last digit of each number.
// Explain why getLastDigit is not working properly - correct the problem
7 changes: 5 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,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 bmi = weight / (height * height);
return Math.round(bmi * 10) / 10;
}

console.log(`The BMI of Yonatan is ${calculateBMI(65, 1.65)}`);
Loading
Loading