London | May-2025 | Mohamed Ibrahim | Sprint-1#521
London | May-2025 | Mohamed Ibrahim | Sprint-1#521sidicamoli wants to merge 19 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Explanation is clear. Well done. I only have a few suggestions and questions.
Sprint-1/1-key-exercises/1-count.js
Outdated
| // Line 3 takes the current value of count (0), adds 1 to it, and assigns the result (1) back to count. | ||
| // The = operator is used for assignment — it sets the variable to a new value. 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?
Sprint-1/1-key-exercises/4-random.js
Outdated
| 1. Math.random() | ||
| Returns a random decimal number between 0 (inclusive) and 1 (exclusive). |
There was a problem hiding this comment.
We can also use the concise and precise interval notation to describe a range of values.
For example, we can say, "Math.random() returns a random number in the interval [0, 1)"
There was a problem hiding this comment.
Thanks! I understand now that interval notation shows the range of values. For example, Math.random() returns a number between 0 (included) and 1 (not included), written as [0, 1). That makes it easier to see the limits clearly
| // 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1); Removes the trailing "p" character from the string by slicing off the last character. | ||
| // 3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); Ensures the number is at least 3 characters long by adding leading zeros if necessary (e.g., "9" becomes "009"). | ||
| // 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); Extracts the pound portion by taking all but the last two characters (e.g., from "399", this becomes "3"). | ||
| // 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); Extracts the last two characters as pence (e.g., from "399", this gives "99"). .padEnd(2, "0") ensures we still get two digits (e.g., from "3" it would become "30"). |
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?
| A; It returns the text the user types in, and stores it in the variable `myName`. | ||
| For example, if I typed "Alice", then `myName` would be "Alice". |
There was a problem hiding this comment.
If we were writing a program that uses prompt() to ask for an input value, how could
the program check if the user clicked "OK" or "Cancel"?
…with interval notation
|
Updated Sprint-1 after review: • Improved explanation for count = count + 1 using the correct term. • Fixed conflict and explained random.js step-by-step with interval notation. • Refined comments in 3-to-pounds.js and removed .padEnd() as it wasn’t needed. • Added details in chrome.md about how prompt() works and how to check for cancel/ok. Thanks to CJ Yuan for the helpful feedback! |
| If the user clicks "Cancel", prompt() returns null. | ||
|
|
||
| Example: | ||
| if (myName = null) { |
There was a problem hiding this comment.
Thanks, I’ve understood it clearly!

Learners, PR Template
Self checklist
Changelist
Sprint-1/2-mandatory-errors/0.jsas requestedQuestions
None for now, thanks!