-
-
Notifications
You must be signed in to change notification settings - Fork 387
London | 26-ITP-May | Dagim Daniel | Sprint 1 | 1-key-exercise -count #1375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
abb16d7
1771147
01932d2
97d3425
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| 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? | ||
| //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? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; | ||
| console.log(age); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
|
|
||
| //The error was ReferenceError: cannot access `cityOfBirth` before initialization | ||
| //by swapping the order of the two lines, the error will be fixed. | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,16 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const cardNumber = "4533787178994213"; | ||
| const last4Digits = cardNumber.slice(-4); | ||
|
Comment on lines
+1
to
2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suppose you were not allowed to modify the statement
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i will use .toString() for conversion. |
||
|
|
||
| console.log(last4Digits); | ||
| // 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 | ||
| // i predict that the code doesn't work its because of two things, first i thought its case sensitive things | ||
| // the second one is the type of variable, i thought the slice method is only for string type variable. | ||
|
|
||
| // 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? | ||
| /* | ||
| I run the code and it gives me an error that says "TypeError: cardNumber.slice is not a function". | ||
| so i checked the type of cardNumber using typeof operator and it returns number. | ||
| */ | ||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
|
|
||
| // I believe this question is about what the error might be. | ||
| // the error is syntaxError: and its because the variable name stats wit a number which is not allowed in Javascript. | ||
| // removing the number or use the number next to the string/s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: To describe a range of numbers, we could use the concise and precise interval notation:
[,]=> inclusion(,)=> exclusionFor example,
[1, 10)means, all numbers between 1 and 10, including 1 but excluding 10.