Skip to content

Commit bd9746a

Browse files
committed
second one done
1 parent b4198c8 commit bd9746a

3 files changed

Lines changed: 47 additions & 23 deletions

File tree

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22

33
// =============> write your prediction here
44

5-
function multiply(a, b) {
6-
console.log(a * b);
7-
}
5+
// the fuction is not returning anything, so the result of multiplying 10 and 32 will be undefined how ever the function
6+
// is still multiplying the two numbers and printing the result to the console
7+
8+
// function multiply(a, b) {
9+
// console.log(a * b);
10+
// }
811

9-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
12+
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1013

11-
// =============> write your explanation here
14+
// // =============> write your explanation here
15+
16+
// // Finally, correct the code to fix the problem
17+
// // =============> write your new code here
18+
function multiply(a, b) {
19+
const result = a * b;
20+
console.log(result);
21+
return result;
22+
}
1223

13-
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
24+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3+
//there is nothing being returned so the function will be undefined
4+
// function sum(a, b) {
5+
// return;
6+
// a + b;
7+
// }
38

4-
function sum(a, b) {
5-
return;
6-
a + b;
7-
}
8-
9-
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
9+
// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010

1111
// =============> write your explanation here
1212
// Finally, correct the code to fix the problem
1313
// =============> write your new code here
14+
function sum(a, b) {
15+
return a + b;
16+
}
17+
18+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

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

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

33
// Predict the output of the following code:
4-
// =============> Write your prediction here
4+
// num is a const so it will al;ways return 3
55

6-
const num = 103;
6+
// const num = 103;
77

8-
function getLastDigit() {
9-
return num.toString().slice(-1);
10-
}
8+
// function getLastDigit() {
9+
// return num.toString().slice(-1);
10+
// }
1111

12-
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
13-
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
14-
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
12+
// console.log(`The last digit of 42 is ${getLastDigit(42)}`);
13+
// console.log(`The last digit of 105 is ${getLastDigit(105)}`);
14+
// console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1515

1616
// Now run the code and compare the output to your prediction
17-
// =============> write the output here
17+
// =============> yes thay all give 3
1818
// Explain why the output is the way it is
19-
// =============> write your explanation here
19+
// because the variable is a consrent
2020
// Finally, correct the code to fix the problem
2121
// =============> write your new code here
2222

2323
// This program should tell the user the last digit of each number.
2424
// Explain why getLastDigit is not working properly - correct the problem
25+
26+
27+
function getLastDigit(num) {
28+
return num.toString().slice(-1);
29+
}
30+
31+
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
32+
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
33+
console.log(`The last digit of 806 is ${getLastDigit(806)}`);

0 commit comments

Comments
 (0)