pxt-calliope/libs/core/helpers.ts
Sam El-Husseini 6f148c14e0 Fix randomInt
2018-06-01 11:42:38 -07:00

17 lines
469 B
TypeScript

namespace console {
export function log(msg: string) {
serial.writeString(msg);
serial.writeString("\r\n");
}
}
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
export function randomBoolean(): boolean {
return Math.floor(Math.randomRange(0, 1) * 2) == 1;
}
}