Skip to content

Commit e897f8b

Browse files
committed
Finished my tasks
1 parent d904467 commit e897f8b

File tree

6 files changed

+59
-3
lines changed

6 files changed

+59
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function capitalise(str) {
99
return str;
1010
}
1111

12-
1312
// =============> write your explanation here
1413
// =============> write your new code here
1514

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function convertToPercentage(decimalNumber) {
1111

1212
return percentage;=
1313
}
14-
1514
console.log(decimalNumber);
1615

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function square(3) {
99

1010
return num * num;
1111
}
12-
1312
// =============> write the error message here
1413

1514
SyntaxError: Unexpected number

Sprint-2/2-mandatory-debug/0.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,17 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1010

1111
// =============> write your explanation here
1212

13+
the function just prints the answer, it dont return it.
14+
15+
so when we try to use it inside the message it shows undefined.
16+
1317
// Finally, correct the code to fix the problem
1418
// =============> write your new code here
19+
20+
function multiply(a, b){
21+
22+
return a * b
23+
}
24+
25+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`)
26+

Sprint-2/2-mandatory-debug/1.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,18 @@ function sum(a, b) {
99
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010

1111
// =============> write your explanation here
12+
13+
the code dont work cuz the return stops the code before it adds the numbers.
14+
15+
so js never does a + b, that’s why it show undefined.
16+
1217
// Finally, correct the code to fix the problem
1318
// =============> write your new code here
19+
20+
function sum(a, b){
21+
22+
return a + b
23+
}
24+
25+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`)
26+

Sprint-2/2-mandatory-debug/2.js

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

3+
it will print 3 for all of them
4+
35
// Predict the output of the following code:
6+
7+
The last digit of 42 is 3
8+
The last digit of 105 is 3
9+
The last digit of 806 is 3
10+
411
// =============> Write your prediction here
512

613
const num = 103;
714

815
function getLastDigit() {
16+
917
return num.toString().slice(-1);
1018
}
1119

@@ -15,9 +23,35 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1523

1624
// Now run the code and compare the output to your prediction
1725
// =============> write the output here
26+
27+
The last digit of 42 is 2
28+
29+
The last digit of 105 is 5
30+
31+
The last digit of 806 is 6
32+
1833
// Explain why the output is the way it is
1934
// =============> write your explanation here
35+
36+
It always shows 3 cuz the function just uses the num at the top (103).
37+
38+
It ignores the numbers we put in () like 42, 105, 806.
39+
40+
We need to let the function take a number as input.
41+
2042
// Finally, correct the code to fix the problem
43+
44+
function getLastDigit(num){
45+
46+
return num.toString().slice(-1)
47+
}
48+
49+
console.log(The last digit of 42 is ${getLastDigit(42)})
50+
51+
console.log(The last digit of 105 is ${getLastDigit(105)})
52+
53+
console.log(The last digit of 806 is ${getLastDigit(806)})
54+
2155
// =============> write your new code here
2256

2357
// This program should tell the user the last digit of each number.

0 commit comments

Comments
 (0)