From f461f4ee4c5ce753e5953da2410fcfc4348f79ec Mon Sep 17 00:00:00 2001 From: Galen Nickel Date: Fri, 18 Jan 2019 07:52:48 -0800 Subject: [PATCH] add examples to 'for of' and 'repeat' (#1794) --- docs/blocks/loops/for-of.md | 20 ++++++++++++++++++++ docs/blocks/loops/repeat.md | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 docs/blocks/loops/for-of.md create mode 100644 docs/blocks/loops/repeat.md diff --git a/docs/blocks/loops/for-of.md b/docs/blocks/loops/for-of.md new file mode 100644 index 00000000..a0cc44c0 --- /dev/null +++ b/docs/blocks/loops/for-of.md @@ -0,0 +1,20 @@ +# @extends + +## #examples + +## Example: Find the highest number + +Find the highest number in a list of numbers. Display the highest number on the screen. + +```blocks +let list: number[] = [] +let highest = 0 +highest = 0 +list = [5, 8, 6, 2, 4, 3, 7, 1] +for (let value of list) { + if (value > highest) { + highest = value + } +} +basic.showNumber(highest) +``` \ No newline at end of file diff --git a/docs/blocks/loops/repeat.md b/docs/blocks/loops/repeat.md new file mode 100644 index 00000000..8c2fcb3d --- /dev/null +++ b/docs/blocks/loops/repeat.md @@ -0,0 +1,16 @@ +# @extends + +## #examples + +## Example: Blinking heart + +Flash the ``heart`` icon on the screen `4` times. + +```blocks +for (let i = 0; i < 4; i++) { + basic.showIcon(IconNames.Heart) + basic.pause(300) + basic.clearScreen() + basic.pause(300) +} +```