-
-
Notifications
You must be signed in to change notification settings - Fork 339
Glasgow | ITP-MAY-2026 | Tuan Nguyen | Sprint 1 | Programming-fundamentals #1307
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
ae2a475
20fb215
ba2b449
4a643cc
8d780b8
54de241
62e8714
041e4fc
1f147eb
9fbf280
fcb1b97
1f8489e
fd5b31a
9b4e1ce
32ba325
559987c
59175e7
f5912ea
b1ce803
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,6 +1,9 @@ | ||
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| /* in line three, the variable count is reassign new value by increment it current value by 1. | ||
| */ | ||
| console.log(count); | ||
|
|
||
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing |
| 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? | ||
| /*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 comment both the line 1 and 2 out and the system should ignore these 2 line and see them as comment. | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| age = age + 1; | ||
| let age = 33; | ||
| age += 1 ; | ||
|
|
||
| console.log(age); | ||
|
|
||
| /*By changing the variable from const to let since const variable value can't be change. I used prefix to increase the value and reassign it right away.*/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; | ||
| console.log(twelveHourClockTime); | ||
| console.log(twentyFourHourClockTime); | ||
|
|
||
| /*For this error I I fix by changing the number 12 and 24 to word variable name because in JS number can't be used to begin writing a variable name */ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,3 +23,31 @@ console.log(result); | |||||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||||||
|
|
||||||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||||||
|
|
||||||
| /* | ||||||
| Answer | ||||||
| a)In this program there are 5 variable declarations: | ||||||
|
Member
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 think you may have missed one - can you spot it? |
||||||
| -const movieLength = 8784; at line 1. | ||||||
| -const remainingSeconds = movieLength % 60; at line 3. | ||||||
| -const totalMinutes = (movieLength - remainingSeconds) / 60; at line 4. | ||||||
| -const remainingMinutes = totalMinutes % 60; at line 6. | ||||||
| -const totalHours = (totalMinutes - remainingMinutes) / 60; at line 7. | ||||||
|
|
||||||
| b) There are only 1 function call in this program. | ||||||
| - console.log(result); at line 10 | ||||||
|
|
||||||
| c)At the line 3 we can see the the expression movieLength % 60, | ||||||
| what is represent is the reminder value after the division movieLength(in second) value by 60%; | ||||||
|
Member
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.
Suggested change
|
||||||
| this is to remind how much left over second left in the movie. | ||||||
|
|
||||||
| d)In line 4, the the expression that is assigned to totalMinutes | ||||||
| represent the value after the math operation if movieLength value and remainingSeconds then divine by 60; | ||||||
|
Member
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. This doesn't quite make sense as a sentence, and also has a few typos - can you try to rewrite it? |
||||||
|
|
||||||
| e)For the variable result it represent the combine total time length of the movie in hour/minutes/second template, for better name for this variable | ||||||
| I would to rename it to formattedMovieDuration. | ||||||
|
Member
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 alternative name! |
||||||
|
|
||||||
| f) After the experimenting with different values of movieLength. As Long as the value in movieLength is a positive integer of second. It will | ||||||
| correctly produce the correct value in hours/minutes/second format. However for to the other value such as float number, string, negative integer | ||||||
| and non numeric value. They might still print out in the format hours/minutes/second but some type will break code such as if string not a number or coma in a string | ||||||
| number, negative value that don't reflect what this code try to do or decimal number that give incorrect result. | ||||||
| */ | ||||||
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 directory actually includes the leading
/- can you fix this?