File tree Expand file tree Collapse file tree 5 files changed +34
-6
lines changed
Sprint-1/2-mandatory-errors Expand file tree Collapse file tree 5 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 1- This is just an instruction for the first activity - but it is just for human consumption
2- We don 't want the computer to run these 2 lines - how can we solve this problem?
1+ //This is just an instruction for the first activity - but it is just for human consumption
2+ //We don't want the computer to run these 2 lines - how can we solve this problem?
3+
4+ //we can solve this by making the above statements as comments using //
Original file line number Diff line number Diff line change 11// trying to create an age variable and then reassign the value by 1
22
3- const age = 33 ;
3+ //const age = 33;
4+ //age = age + 1;
5+
6+ /* the mistake in the above code is the use of const which we use only to save the constant values
7+ which we don't want to change in the future; therefore, in the above example we would declare age
8+ as a variable rather than constant to solve the issue.*/
9+
10+ let age = 33 ;
411age = age + 1 ;
12+ console . log ( age ) ;
Original file line number Diff line number Diff line change 33
44console . log ( `I was born in ${ cityOfBirth } ` ) ;
55const cityOfBirth = "Bolton" ;
6+
7+ //the above code is not working because you are printing or using the cityOfBirth constant before initializing it
Original file line number Diff line number Diff line change 11const cardNumber = 4533787178994213 ;
2- const last4Digits = cardNumber . slice ( - 4 ) ;
2+ // const last4Digits = cardNumber.slice(-4);
33
44// The last4Digits variable should store the last 4 digits of cardNumber
55// However, the code isn't working
66// Before running the code, make and explain a prediction about why the code won't work
77// Then run the code and see what error it gives.
88// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
99// Then try updating the expression last4Digits is assigned to, in order to get the correct value
10+
11+ //I predicted that the code is not working because the cardNumber is a constant value and cannot be changed
12+ // but actually we are not changing the value of cardNumber we are just slicing it which will be stored in a different variable
13+ //and the cardNumber value will remain the same
14+ //After running the code, I have realized that the code is not working because cardNumber is a number and the slice is a method in String class
15+ //so, in order to make it work, we need to change cardNumber to String before calling the slice method
16+
17+ const last4Digits = ( cardNumber + "" ) . slice ( - 4 ) ;
18+ console . log ( "Last four digits of card are : " + last4Digits ) ;
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+ const twelveHourClockTime = "20:53" ;
5+ const twentyFourhourClockTime = "08:53" ;
6+
7+ /*in javascript and also many other programming languages, we can't start the name of an identifier
8+ // with a number, therefore, I have changed that to text form*/
9+
You can’t perform that action at this time.
0 commit comments