Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sprint-2/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -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
//By adding two slashes at the begining of each line.
12 changes: 9 additions & 3 deletions Sprint-2/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
@@ -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)
//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.
7 changes: 6 additions & 1 deletion Sprint-2/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 7 additions & 2 deletions Sprint-2/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
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
// Before running the code, make and explain a prediction about why the code won't work
// 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);
11 changes: 9 additions & 2 deletions Sprint-2/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -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)