-
-
Notifications
You must be signed in to change notification settings - Fork 546
London | 26-ITP-Sep | Rhoda Ajiroba | Sprint 2 | JavaScript Fundamentals #1572
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
d0c831a
6756eba
b865732
0ae0a4e
b2a1379
8aed09f
c322137
3a442db
139aee8
feadfb2
23c71b9
770d48e
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,5 @@ | ||
| // 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}`); | ||
|
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. Good fix. Why did the original order fail? Which error was it? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| const last4Digits = cardNumber.toString().slice(-4); | ||
|
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. Good fix. This one asks for a prediction first. What did you expect to go wrong? What error did node give? Did it match your prediction? Write your answers below line 9. |
||
|
|
||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const twelveHourClockTime = "8:53pm"; | ||
|
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. Good names. Why could the original names not be used? Which error was it? |
||
| const twentyFourHourClockTime = "20:53"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,24 @@ console.log(result); | |
| // For the piece of code above, read the code and then answer the following questions | ||
|
|
||
| // a) How many variable declarations are there in this program? | ||
| // Answer: There are 6 variable declarations. | ||
|
|
||
| // b) How many function calls are there? | ||
| // Answer: There is 1 function call: console.log(result). | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| // Answer: movieLength % 60 gives the remainder after dividing movieLength by 60. | ||
| // This represents the remaining seconds after converting the time into whole minutes. | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| // Answer: It subtracts the remaining seconds from movieLength and divides by 60. | ||
| // This gives the total number of whole minutes in the movie. | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // Answer: result represents the movie length formatted as hours, minutes and seconds. | ||
| // A better variable name would be formattedMovieLength. | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // Answer: No, it will not format all values correctly. | ||
| // For example, single-digit minutes or seconds will not have a leading zero. | ||
|
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. Good, the missing zeros are one problem. Now try |
||
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.
The fix works. Why did the original line fail? Which of the three error names was it?