From a60346d4f40f1591c8c8a1b7aaf49a7ca5d3028a Mon Sep 17 00:00:00 2001 From: Galen Nickel Date: Thu, 7 Sep 2017 14:16:56 -0700 Subject: [PATCH] Add 'randomBoolean' doc page. (#530) --- docs/blocks/math/random-boolean.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docs/blocks/math/random-boolean.md diff --git a/docs/blocks/math/random-boolean.md b/docs/blocks/math/random-boolean.md new file mode 100644 index 00000000..e32b6d59 --- /dev/null +++ b/docs/blocks/math/random-boolean.md @@ -0,0 +1,29 @@ +# random Boolean + +Returns a pseudo-random boolean value that is either `true` or `false`. + +```sig +Math.randomBoolean() +``` + +## Returns + +* a pseudo-random [boolean](types/boolean) that is either `true` or `false`. + +## Example + +Make your @boardname@ do a coin toss when it's dropped softly. Have the LEDs show 'heads' or 'tails' as the result of the toss. + +```blocks +input.onGesture(Gesture.FreeFall, () => { + if (Math.randomBoolean()) { + basic.showIcon(IconNames.Happy) + } else { + basic.showIcon(IconNames.Sword) + } +}) +``` + +## See Also + +[random](/reference/math/random) \ No newline at end of file