From dfa316b2d270a1732d10e3bcb4bf032d85169fdf Mon Sep 17 00:00:00 2001 From: Tom Ball Date: Tue, 13 Nov 2018 15:12:56 -0800 Subject: [PATCH] Update reactive.md --- docs/device/reactive.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/device/reactive.md b/docs/device/reactive.md index 950c9129..85fa508c 100644 --- a/docs/device/reactive.md +++ b/docs/device/reactive.md @@ -148,17 +148,18 @@ Through this example, we have seen that the micro:bit scheduler enables you to c As a result, you can easily add a new capability to the micro:bit by just adding a new subprogram. For example, if you want to add a reset feature to the counter program, all you need to do is add a new event handler for a press of button **B** that sets the global variable "count" to zero, as shown below: ```typescript -function countButtonPressesWithReset() { - let count = 0 - input.onButtonPressed(Button.A, () => { - count = count + 1 - }) - basic.forever(() => { - basic.showNumber(count) - }) - input.onButtonPressed(Button.B, () => { - count = 0 - }) -} +let count = 0 + +input.onButtonPressed(Button.A, () => { + count = count + 1 +}) + +basic.forever(() => { + basic.showNumber(count) +}) + +input.onButtonPressed(Button.B, () => { + count = 0 +}) ```