Search code examples
javascripttypescriptbbc-microbit

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


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.


Solution

  • 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: