London | JAN-2026 ITP | Ebrahim Moqbel | Sprint 1 | Coursework#1074
London | JAN-2026 ITP | Ebrahim Moqbel | Sprint 1 | Coursework#1074Ebrahim-Moqbel 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.
Sprint-1/1-key-exercises/4-random.js
Outdated
| // math.floor will make the number as a whole and remove any decimals or more likely to round the the nearest whole number | ||
| // math.random returns a random number in [0,1) | ||
| // (maximum - minimum + 1) provide a range of generated random number | ||
| // num is a random whole number [1,100) |
There was a problem hiding this comment.
Can the value of num be 100? That is, canthe generated random number include 100?
There was a problem hiding this comment.
No the notation ( , ) would exclude the number therefore 100 wouldn't be generated.
There was a problem hiding this comment.
You figured out Math.random returns a random number in [0, 1).
Can you use the interval notation to describe what each of these expressions does, and the range of the numbers it may produce?
Math.random() * (maximum - minimum + 1)Math.floor(Math.random() * (maximum - minimum + 1))Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
There was a problem hiding this comment.
- math.random() would generate a random number between 0 and 1 multiply it by the maximum inclusively subtracted the minimum exclusively and that's why we have added one.
- math.floor() would round the decimal number to the nearest value
- math.floor() would do the same and the addition at the end would just ad to the rounded number the minimum
There was a problem hiding this comment.
Can you instead show the interval of the values that can be generated by each of the expressions?
I will mark this PR as complete first.
Note: Math.floor() does not round a number to the nearest integer.
|
What about this comment: #1074 (comment) Please note that in CYF courses, the recommended way to inform the reviewer of your changes is to do both of the following:
|
Learners, PR Template
Self checklist
Changelist
completed all of the bellow filles :
Key exercises
Mandatory errors
Mandatory interpret
Stretch exploration
Questions
N/A