File tree Expand file tree Collapse file tree 3 files changed +28
-5
lines changed
Sprint-1/2-mandatory-errors Expand file tree Collapse file tree 3 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 11// Currently trying to print the string "I was born in Bolton" but it isn't working...
22// what's the error ?
3-
4- console . log ( `I was born in ${ cityOfBirth } ` ) ;
53const cityOfBirth = "Bolton" ;
4+ console . log ( `I was born in ${ cityOfBirth } ` ) ;
5+
6+ //Code was correct, I just shifted the const part to the top of the code block.
Original file line number Diff line number Diff line change 11const cardNumber = 4533787178994213 ;
2- const last4Digits = cardNumber . slice ( - 4 ) ;
2+ const last4Digits = cardNumber . toString ( ) . slice ( - 4 ) ;
3+
4+
5+ console . log ( last4Digits ) ;
36
47// The last4Digits variable should store the last 4 digits of cardNumber
58// However, the code isn't working
69// Before running the code, make and explain a prediction about why the code won't work
710// Then run the code and see what error it gives.
811// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
912// Then try updating the expression last4Digits is assigned to, in order to get the correct value
13+
14+
15+ // Prediction; code wont work because slice is for strings, not numbers.
16+
17+ // after running the code, I got an error saying "cardNumber.slice is not a function".
18+
19+ // It's what I predicted.
20+
21+ // to fix the code I need to convert number to string first, then slice it.
Original file line number Diff line number Diff line change 1- const 12 HourClockTime = "20:53" ;
2- const 24 hourClockTime = "08:53" ;
1+ //const 12HourClockTime = "20:53";
2+ //const 24hourClockTime = "08:53";
3+
4+
5+ // problem is in javascript we cant start a variable name with a number.
6+
7+ // correct way is:
8+
9+ const . twelveHourClockTime = "20:53" ;
10+ const twentyFourHourClockTime = "08:53" ;
11+
12+ console . log ( `The time in 12-hour format is ${ twelveHourClockTime } and in 24-hour format is ${ twentyFourHourClockTime } ` ) ;
You can’t perform that action at this time.
0 commit comments