Skip to content

Commit dc9d08d

Browse files
debug2604debug2604
authored andcommitted
Wrote the TypeError below my prediction line 8. Also ensured Prettier applied
1 parent 5d16528 commit dc9d08d

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// The last4Digits variable should store the last 4 digits of cardNumber
2-
// However, the code isn't working
3-
// Before running the code, make and explain a prediction about why the code won't work
4-
// Then run the code and see what error it gives.
5-
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
6-
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
7-
// The code would result a TypeError. Expectation about the error : cardNumber is assigned a number value, a .slice function does not work on number
8-
// The constant last4Digits should be assigned to a String (cardNumber) to perform .slice function.
9-
const cardNumber = 4533787178994213;
10-
const last4Digits = String(cardNumber).slice(-4);
11-
12-
console.log(last4Digits);
1+
// The last4Digits variable should store the last 4 digits of cardNumber
2+
// However, the code isn't working
3+
// Before running the code, make and explain a prediction about why the code won't work
4+
// Then run the code and see what error it gives.
5+
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
6+
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
7+
// Expectation about the error : cardNumber is assigned a number value, a .slice function does not work on number
8+
// The constant last4Digits should be assigned to a String (cardNumber) to perform .slice function.
9+
// The code would result a TypeError.
10+
const cardNumber = 4533787178994213;
11+
const last4Digits = String(cardNumber).slice(-4);
12+
13+
console.log(last4Digits);

0 commit comments

Comments
 (0)