diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index 8db780fec..1c320ee8a 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,3 +1,3 @@ //This is just an instruction for the first activity - but it is just for human consumption //We don't want the computer to run these 2 lines - how can we solve this problem? -//By adding two slashes \ No newline at end of file +//By adding two slashes at the begining of each line. diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index a016ddc8d..070ae809b 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,6 +1,12 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; -age == age + 1; +let age = 33; +age = age + 1; -console.log(age) \ No newline at end of file +//const age = 33; +//age == age + 1; + +console.log(age) + +//This is a type error. For the expected result of 34, age should not be declared as a constant. +//let should be used instead of const because const is a constant variable and cannot be reassigned. \ No newline at end of file diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index 5087483e7..1784fca15 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,5 +1,10 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? -console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); + + +//console.log(`I was born in ${cityOfBirth}`); +//const cityOfBirth = "Bolton"; +//The error is that the variable should be declared as a constant before it is used in the console.log statement. diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index 463f57a4b..53febfeb3 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,5 +1,4 @@ -const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); + // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +6,9 @@ const last4Digits = cardNumber.slice(-4); // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? // Then try updating the expression last4Digits is assigned to, in order to get the correct value +// Expectation about the error : cardNumber is assigned a number value, a .slice function does not work on number +// The constant last4Digits should be assigned to a String (cardNumber) to perform .slice function. +const cardNumber = 4533787178994213; +const last4Digits = String(cardNumber).slice(-4); + +console.log(last4Digits); diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 461663dfc..6e8b4576b 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,9 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +// const 12HourClockTime = "8:53pm"; +// const 24hourClockTime = "20:53"; + // An identifier cannot start with a numberical value + +const TweleveHourClockTime = "8:53pm"; +const TwentyFourhourClockTime = "20:53"; + +console.log(TweleveHourClockTime) +console.log(TwentyFourhourClockTime) \ No newline at end of file