Where is the Micro:Bit TypeScript randint() Function Documented?

128 Views Asked by At

I am trying* to teach a class of high school students to transition from block coding to JavaScript (really Static TypeScript) on the Micro:Bit.

The pickrandom block translates into a call to randint() I would have expected a call to Math.randint() but apparently randint() is a global function in TypeScript.

The first question the kids are going to ask is "Where can I find out about other global functions?" and, after almost two hours with Google, I can't find the answer to that question.

So, where is randint() documented and where is a list of other such functions?

* Context: I'm a retired college teacher who "became volunteered" to help out during the pandemic.

2

There are 2 best solutions below

2
On BEST ANSWER

It might be worth having a read of the documentation from Lancaster University. Squeezing the high level languages into something that runs on a tiny micro-controller means connecting into the Device Abstraction Layer (DAL) and so things like the randint are micro:bit specific.

As a result, for the different languages they look very similar:

2
On

It is not really a JavaScript / Typescript issue. There is no randint() function in these languages. It is micro:bit specific. To see all available commands see the documentation at https://makecode.microbit.org/reference