Skip to content

Commit 9b20e8f

Browse files
committed
practicing
1 parent ba7388c commit 9b20e8f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
66
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
77

8+
//my answer:
89
//slice() only works for string or Array,cardNumber is number so i predict that the computer will give TypeError. When i
910
//run this Code, my prediction is right. In order to fix it, first cast to string first:
1011

1112
const cardNumber=4533787178994213;
1213

13-
//then conver to number
14+
//then convert to string
1415
const last4Digits = cardNumber.toString().slice(-4);
1516
console.log(last4Digits);
1617

1718
// or i can put quotes on cardNumber which will be string
18-
const cardNumber ="4533787178994213"
19-
const last4Digits = cardNumber.slice(-4);
20-
console.log(last4Digits)
19+
const cardNumber1 ="4533787178994213"
20+
const last4Digits1 = cardNumber1.slice(-4);
21+
console.log(last4Digits1)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const 24hourClockTime = "08:53";
44
// cost 12HourClockTime = "20.53" is wrong code because 20 is more than 12 and variable name can not start with digital in JavaScript.
55
// The right coe should be:
66

7-
const TwelveHourClockTime = "08:53"
7+
const TwelveHourClockTime = "08:53 pm"
88
const TwentyFourHourClockTime = "20:53"

0 commit comments

Comments
 (0)