-
-
Notifications
You must be signed in to change notification settings - Fork 272
Glasgow | 25-ITP-SEP | Hanna Mykytiuk | Sprint 1 | coursework/sprint-1 #732
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 1 commit
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,4 @@ | ||
| 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? | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
|
|
||
| //We have to add " // " |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const 24hourClockTime = "08:53"; | ||
|
|
||
| //Explenation: the name of value in JS can not start with numbers. | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
| const movieLength = -8784; // length of movie in seconds (8784) | ||
|
|
||
| const remainingSeconds = movieLength % 60; | ||
| //console.log(`Remaining Seconds:${remainingSeconds}`) | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
||
| const remainingMinutes = totalMinutes % 60; | ||
|
|
@@ -12,14 +13,16 @@ 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? | ||
|
|
||
| //6 | ||
| // b) How many function calls are there? | ||
|
|
||
| //1 | ||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
|
|
||
| // %-this is remaider operator that help us get remaining. In this case, dividing MovieLength % 60 returned | ||
| // remainder. It is not a typical mathematic division, it is division where we can get remainder. | ||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
|
|
||
| // Mean the subtraction remaider(second) from the total length (in second) and divide by 60, because we need Minutes (1 min = 60 sec) | ||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
|
||
| //time | ||
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| //It works with a different values(negative and positive numbers). | ||
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.
If you are concatenating values together, do you need the surrounding
${}?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.
No, we need them only when combining text with variables. I have removed them.