docs fixes
This commit is contained in:
parent
4b01210b0d
commit
14c76b49f1
7
docs/blocks/loops.md
Normal file
7
docs/blocks/loops.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# @extends
|
||||||
|
|
||||||
|
### #specific
|
||||||
|
|
||||||
|
```
|
||||||
|
basic.forever(() => {});
|
||||||
|
```
|
@ -1,9 +1,49 @@
|
|||||||
# @extends
|
# @extends
|
||||||
|
|
||||||
### #letexample
|
#### #letexample
|
||||||
|
|
||||||
A variable is created for the number returned by the [brightness](/reference/led/brightness) function.
|
A variable is created for the number returned by the [brightness](/reference/led/brightness) function.
|
||||||
|
|
||||||
```block
|
```block
|
||||||
let b = led.brightness();
|
let b = led.brightness();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### #readvariableexample
|
||||||
|
|
||||||
|
For example, the following code shows the value stored in `counter` on the LED screen:
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
let counter = 1;
|
||||||
|
basic.showNumber(counter);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### #updatevariableexample
|
||||||
|
|
||||||
|
The following code sets `counter` to 1 and then increments `counter` by 10:
|
||||||
|
|
||||||
|
```block
|
||||||
|
let counter = 1;
|
||||||
|
counter = counter + 10;
|
||||||
|
basic.showNumber(counter);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### #whyusevariablesexample
|
||||||
|
|
||||||
|
A counter is a great example:
|
||||||
|
|
||||||
|
```block
|
||||||
|
let counter = 0;
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
counter = counter + 1;
|
||||||
|
basic.showNumber(counter);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### #localvariableexample
|
||||||
|
```block
|
||||||
|
// x does NOT exist here.
|
||||||
|
if (led.brightness() > 128) {
|
||||||
|
// x exists here
|
||||||
|
let x = 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user