London | Jan2026 | Ihor Taradaiko | Sprint 1 | Coursework/sprint 1#934
London | Jan2026 | Ihor Taradaiko | Sprint 1 | Coursework/sprint 1#934ihortar wants to merge 13 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // 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 | ||
| //It takes the current value of count, add 1 to it No newline at end of file |
There was a problem hiding this comment.
Operation like count = count + 1 is very common in programming, and there is a programming term describing such operation.
Can you find out what one-word programming term describes the operation on line 3?
| // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | ||
|
|
||
| let initials = ``; | ||
| let initials = `${firstName.charAt()}${middleName.charAt()}${lastName.charAt()} `; |
There was a problem hiding this comment.
Normally, we specify an argument in the function call .charAt() to indicate the position of the character to return. For example, firstName.charAt(0) to extract the first character.
Can you find out why the statement on line 8 can still work?
We don't recommend this practice. Can you update the code on line 8 to explicitly pass an argument to each function .charAt() to extract the first character?
| // Try breaking down the expression and using documentation to explain what it means | ||
| // It will help to think about the order in which expressions are evaluated | ||
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
| //results: 4,23,91,46 the program is giving you a random number while math.random give you a random decimal number math.floor rounds the total number up No newline at end of file |
There was a problem hiding this comment.
Can you give a precise description what each of these expressions does, and the range of the numbers it may produce?
Math.random()Math.random() * (maximum - minimum + 1)Math.floor(Math.random() * (maximum - minimum + 1))Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
Note: To describe a range of numbers, we can use the concise and precise interval notation:
[,]=> inclusion(,)=> exclusion
For example, [1, 10) means, all numbers between 1 and 10, including 1 but excluding 10.
| const HourClockTime24 = "20:53"; | ||
| const hourClockTime12 = "08:53"; |
There was a problem hiding this comment.
In JS naming convention, variable names usually begins with a lowercase letter. Names starting with an uppercase letter are used for built-in and custom data types (e.g., Math)
|
|
||
| // a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
|
|
||
| //4,5,11 |
There was a problem hiding this comment.
Can you also indicate the total number of function calls? (It is not three).
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
|
|
||
| //math expression |
There was a problem hiding this comment.
The question means to ask, "what does (movieLength - remainingSeconds) / 60 calculate?"
|
|
||
| //maybe timeLeft or similar |
There was a problem hiding this comment.
When I see a variable named timeLeft, I may think
- It represents a remaining time.
- Is looks like it is storing a number.
- What is the unit of the time? Is it in hours or seconds?
Can you think of a more meaningful name that could more accurately describe the value it stores.
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
|
|
||
| //5. takes the last 2 digits as the pence from paddedPenceNumberString |
There was a problem hiding this comment.
Could we expect this program to work as intended for any valid penceString if we deleted .padEnd(2, "0") from the code?
In other words, do we really need .padEnd(2, "0") in this script?
| What is the return value of `prompt`? | ||
| //shows a pop-up to enter a name / stores and shows name | ||
| What effect does calling the `prompt` function have? //shows pop-up form | ||
| What is the return value of `prompt`? //if myName is set returns myName value |
There was a problem hiding this comment.
Can you describe the return value of prompt() as I am someone who has never used the function before?
The current description does not quite tell me exactly what the function returns.
Changelist
Completed the following exercises:
Key Exercises
Mandatory Errors
Mandatory Interpret