pxt-calliope/libs/core/helpers.ts
2020-08-19 22:03:58 +02:00

10 lines
330 B
TypeScript

namespace Math {
/**
* Generates a `true` or `false` value randomly, just like flipping a coin.
*/
//% blockId=logic_random block="pick random true or false"
//% help=math/random-boolean weight=0 color=712672
export function randomBoolean(): boolean {
return Math.randomRange(0, 1) === 1;
}
}