File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
Sprint-1/2-mandatory-errors Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 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
1112const cardNumber = 4533787178994213 ;
1213
13- //then conver to number
14+ //then convert to string
1415const last4Digits = cardNumber . toString ( ) . slice ( - 4 ) ;
1516console . 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 )
Original file line number Diff line number Diff 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 "
88const TwentyFourHourClockTime = "20:53"
You can’t perform that action at this time.
0 commit comments