Using a while loop to generate a number of eaten cupcakes smaller than the amount made is unnecessary, it's better to generate the amount of cupcakes and then use that number as the ceiling for the amount of eaten cupcakes.
while
function randInt(start, end) { return Math.floor(Math.random() * (end - start)) + start } const made = randInt(0, 50) const eaten = randInt(0, made)
Yes it's make sense to use start-end range for eaten and or made cakes and should be better. Already updated my code on sandbox
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Using a
whileloop to generate a number of eaten cupcakes smaller than the amount made is unnecessary, it's better to generate the amount of cupcakes and then use that number as the ceiling for the amount of eaten cupcakes.Yes it's make sense to use start-end range for eaten and or made cakes and should be better. Already updated my code on sandbox