randomNumber() vs math.Random()

Currently on Unit 3 Lesson 6.
Is randomNumber() only used in GameLab or is it also used in javascript?
Why aren’t students taught to used math.Random() to generate random numbers in WebLab? Does Weblab use a pseudocode?


Good morning. Do you mean Game Lab?

In text mode, math.Random() should work if you want to teach it. My best guess is that math.Random generates a decimal and for students new to programming, using whole numbers is more in line with what they would expect and want to use.

The engineers created a number of “built in” functions such as the random block and many others on top of the javascript framework to make Game Lab a friendly and easy to use tool for younger students newer to programming.

Pseudocode may not quite be the right term for it, but they have chosen to create some functions that are more simple for new programmers. Another example is velocity and another example is createEdgeSprites. These just make the experience easier for those just getting started.

In the “real world”, programmers use pre-existing code all of the time by implementing libraries of code created by other programmers to do the exact same thing… simplify their code and make it easier to get their jobs done.

Hope this helps?


1 Like

I did mean GameLab. my apologies.
And thank you so much for that response! It definitely helped.