Skip to content

Commit c914559

Browse files
committed
fixed answers for 1-count.js, 4-random.js, and 0.js, 1.js, 2.js, 3.js in 2-mandatory-errors. 2-mandatory-errors, original bugs are fixed.
1 parent c33ffe5 commit c914559

7 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎Sprint-2/1-key-exercises/1-count.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ count = count + 1;
55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
66
// Describe what line 3 is doing, in particular focus on what = is doing
77

8-
= mean assignment operator. Computer will calculate the result of "count + 1" and update the variable with the result.
9-
In this question, variable "count" changed from 0 to 1.
8+
//= mean assignment operator. Computer will calculate the result of "count + 1" and update the variable with the result.
9+
//In this question, variable "count" changed from 0 to 1.

‎Sprint-2/1-key-exercises/4-random.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1010

1111
console.log(num)
1212

13-
math.floor is round down the number returns to largest integer less than or equal to a given number.
14-
math.random() could generate the number from 0 to <1 b random.
15-
maximum refer to 100 and minimum refer to 0.
16-
The calculation of num is different everytime because of math.random()
13+
//math.floor is round down the number returns to largest integer less than or equal to a given number.
14+
//math.random() could generate the number from 0 to <1 b random.
15+
//maximum refer to 100 and minimum refer to 0.
16+
//The calculation of num is different everytime because of math.random()

‎Sprint-2/2-mandatory-errors/0.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
This is just an instruction for the first activity - but it is just for human consumption
22
We don't want the computer to run these 2 lines - how can we solve this problem?
33

4-
adding // before the lines.
4+
//adding // before the lines.

‎Sprint-2/2-mandatory-errors/1.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// trying to create an age variable and then reassign the value by 1
22

3-
const age = 33;
3+
let age = 33;
44
age = age + 1;
55

66
console.log(age)
77

8-
The error is "Assignment to constant variable." Constant value could not be alternated.
9-
if line 3 const changed to let the code could be executed.
8+
//The error is "Assignment to constant variable." Constant value could not be alternated.
9+
//if line 3 const changed to let the code could be executed.

‎Sprint-2/2-mandatory-errors/2.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
33

4-
console.log(`I was born in ${cityOfBirth}`);
54
const cityOfBirth = "Bolton";
5+
console.log(`I was born in ${cityOfBirth}`);
6+
67

7-
Initialization should access before the declaration.
8+
//Initialization should access before the declaration.

‎Sprint-2/2-mandatory-errors/3.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
const cardNumber = 4533787178994213;
1+
const cardNumber = '4533787178994213';
22
const last4Digits = cardNumber.slice(-4);
33

4+
console.log(last4Digits)
5+
46
// The last4Digits variable should store the last 4 digits of cardNumber
57
// However, the code isn't working
68
// Before running the code, make and explain a prediction about why the code won't work
79
// Then run the code and see what error it gives.
810
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
911
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1012

11-
slice is for text or array only. Need to change card number from number to text. Add ''for 4533787178994213.
13+
//slice is for text or array only. Need to change card number from number to text. Add ''for 4533787178994213.

‎Sprint-2/2-mandatory-errors/4.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const twelveHourClockTime = "8:53pm";
22
const twentyFourHourClockTime = "20:53";
33

4-
//integer/number could not start for the initiation.
4+
//integer and number could not start for the initiation.

0 commit comments

Comments
 (0)