London | 26-ITP-May | Eyob Zeray | Sprint 1 | course work#1543
London | 26-ITP-May | Eyob Zeray | Sprint 1 | course work#1543eyob-tech wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
| // 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 | ||
| // num is a random whole number between 1 and 100. Math.random() gives a decimal between 0 and 1, multiplying it stretches that range to 0-100, Math.floor rounds it down to a whole number, and + minimum shifts it so the lowest possible value is 1 instead of 0. |
There was a problem hiding this comment.
Your answer is generally correct and I can also basically understand the meaning. Just the clarity can be improved a bit, for example:
- "whole number" may better be expressed in standard mathematical term "integer";
- "
Math.random()gives a decimal between 0 and 1" would actually be including 0 but excluding 1; - after multiply, "it stretches that range to 0-100" including 0 but excluding 100;
- after rounding, it becomes an integer within the range 0-99 including 0 and including 99;
- after adding
minimum, "shifts it so the lowest possible value is 1" and also the highest possible value is 100; - and as a result,
numwould be a random integer generated betweenminimumandmaximuminclusive.
There was a problem hiding this comment.
Thanks so much for taking the time to review this and for the detailed feedback! That really helps clarify things - especially the point about inclusive/exclusive ranges, I hadn't thought about it that precisely. I'll keep "integer" and that level of detail in mind for future explanations. Really appreciate it!
|
Your answers or code fixes for this exercise look pretty well - except the |
London | 26-ITP-May | Eyob Zeray | Sprint 1 | Structuring and Testing Data
Learners, PR Template
Self checklist
Changelist
Completed Sprint 1 exercises: key exercises (count, initials, paths, random), fixed all mandatory errors, and answered the interpretation questions for percentage change, time format, and pence-to-pounds conversion.