-
-
Notifications
You must be signed in to change notification settings - Fork 309
Glasgow | Jan-26 | Elisabeth Matulian | Sprint 1 | Coursework #936
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
de40d9d
697d88c
519042c
4b1a9d9
4d7676a
c007b11
de87e88
98976cf
2c37761
984ab50
04ae366
22e28cd
6f38725
2949452
3ad69fa
dcaad30
f66258c
8962e17
e88aa97
88000ae
4013faf
6613221
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,4 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // 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}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| const cardNumber = 4533787178994213; | ||
| 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 | ||
| // .slice() method works with String type, not with Number type. Therefore there will be an error | ||
| // 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 | ||
| // the error is: "TypeError: cardNumber.slice is not a function" this matches my prediction. The error occurred because the method doen't work with Number type. I've changed cardNumber to a String when added quotes around the number. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const ClockTime12Hour = "20:53"; | ||
| const ClockTime24Hour = "08:53"; | ||
| // variable names cannot start with a number in JavaScript syntax | ||
|
Comment on lines
+1
to
+3
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. Good comment. I would advise you use camelCase as your variable naming convention instead of PascalCase as that is more suitable for class names. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,11 @@ In the Chrome console, | |
| invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
|
||
| What effect does calling the `alert` function have? | ||
| Answer: A window pops up in the browser with the text “Hello world!” | ||
|
|
||
| Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. | ||
|
|
||
| What effect does calling the `prompt` function have? | ||
| Answer: A window pops up in the browser with a text input field | ||
| What is the return value of `prompt`? | ||
| Answer: the text that I entered in the input field that is stored in myName variable | ||
|
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. Good explanation, but you need to learn to explicitly state the data type you are referring to when answering questions from the task. |
||
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.
Now, you did the right thing by explaining your reasoning to debug the error. I would suggest applying a much cleaner way to convert the variable into a string without redeclaring it. You can look into that method using MDN docs.