File tree Expand file tree Collapse file tree 5 files changed +40
-5
lines changed
Sprint-1/2-mandatory-errors Expand file tree Collapse file tree 5 files changed +40
-5
lines changed Original file line number Diff line number Diff line change 1+
12This 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+ We don 't want the computer to run these 2 lines - how can we solve this problem?
4+
5+ //solution: Simply comment the lines.
6+ // 1- single line comment like: // example ...
7+ // 2- multiline comment like : /* a, b, c */
8+ // comments are for instruction of guidance of who will read our codes, but the computer wont read them.
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
33const age = 33 ;
4- age = age + 1 ;
4+ //age = age + 1;
5+
6+ // we can't do that with const variable, because JS locks the reference.
7+ // the best choice is to use "let" variable.
8+ let age2 = 33 ;
9+ age2 = age2 + 1 ; // or age++ if wanna increase by "1";
10+ console . log ( age2 ) ;
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 ?
33
4- console . log ( `I was born in ${ cityOfBirth } ` ) ;
54const cityOfBirth = "Bolton" ;
5+ console . log ( `I was born in ${ cityOfBirth } ` ) ;
6+ //const cityOfBirth = "Bolton";
7+
8+ // the problem is that our variable is not declared when we print it.
9+ // to make it work, we should declare our "cityOfBirth" variable before we print 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);
3+ let str = cardNumber . toString ( ) . slice ( - 4 ) ;
4+ const last4Digits = Number ( str ) ;
5+ console . log ( `${ last4Digits } is the last 4 digits of ${ cardNumber } ` ) ;
6+
7+ //console.log(typeof last4Digits);
8+
9+ // 1- the code is not working because 'slice()' method is not working with numbers.
10+ // 2- it gives "type error" cardNumber.slice is not a function.
11+ // 3- my prediction was correct as I studied the slice method and knew it.
312
413// The last4Digits variable should store the last 4 digits of cardNumber
514// However, the code isn't working
Original file line number Diff line number Diff line change 1+ /*
12const 12HourClockTime = "20:53";
2- const 24 hourClockTime = "08:53" ;
3+ const 24hourClockTime = "08:53";
4+ */
5+ // As far as I know we can not start a variable name with a number in JS.
6+ // Therefore these variables throw error.
7+ // we can start the name of a variable with letters a-z, A-Z, _ ,and $ .
8+ // This is how we correctly name our variables:
9+ const twelveHourClockTime = "20:53" ;
10+ const twenty4HourClockTime = "08:53" ;
11+ console . log ( `Twelve-hour clock: ${ twelveHourClockTime } ` ) ;
12+ console . log ( `24-hour clock: ${ twenty4HourClockTime } ` ) ;
You can’t perform that action at this time.
0 commit comments