Docs: Change default value in Javascript. (#2540)

* Change default value in Javascript.

Per @microbit-mark 's suggestion, add an example of how to change the default interval value by switching to Javascript.

* edits to new example
This commit is contained in:
Nicole Parrot
2019-12-01 23:15:02 -05:00
committed by Peli de Halleux
parent e638a5973f
commit aa0476c1da

View File

@ -9,7 +9,7 @@ basic.showIcon(IconNames.Heart)
## Parameters
* ``icon``, the identifier of the icon to display
* ``interval`` (optional), the time to display in milliseconds. default is 400.
* ``interval`` (optional), the time to display in milliseconds. default is 600.
## Example
@ -21,6 +21,38 @@ basic.pause(1000)
basic.showIcon(IconNames.Sad)
```
## Beating Heart
You can create a beating heart by using the forever block as follows:
```blocks
basic.forever(function () {
basic.showIcon(IconNames.Heart)
basic.showIcon(IconNames.SmallHeart)
})
```
## Fast Beating Heart
You could slow down the previous animation by inserting a pause block:
```block
basic.pause(1000)
```
...but how would you speed it up?
You can change the default pause value, which is set in the ``interval`` parameter, to be smaller than `600` by changing it in the JavaScript editor.
This JavaScript code creates a crazy fast heart beat! Did you know that a hamster's heart beats at a rate this fast?
```typescript
basic.forever(function () {
basic.showIcon(IconNames.Heart, 60)
basic.showIcon(IconNames.SmallHeart, 60)
})
```
## See also
[showLeds](/reference/basic/show-leds)
[showLeds](/reference/basic/show-leds)