2017-03-14 20:07:17 +01:00
|
|
|
# @extends
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2017-03-14 20:07:17 +01:00
|
|
|
## #examples
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Example: ``AND`` operator
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
This example turns on LED `3 , 3`, if LEDs `1 , 1` and `2 , 2` are both on:
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
if (led.point(1,1) && led.point(2,2)) {
|
|
|
|
led.plot(3,3)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Example: Comparisons of numbers and strings
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
|
|
|
|
|
|
|
|
```blocks
|
2016-12-19 23:09:35 +01:00
|
|
|
input.onButtonPressed(Button.A, () => {
|
2018-04-21 19:52:09 +02:00
|
|
|
let x = Math.randomInt(5)
|
2016-12-19 23:09:35 +01:00
|
|
|
if(x < 5) {
|
|
|
|
basic.showString("low");
|
|
|
|
} else {
|
|
|
|
basic.showString("high");
|
|
|
|
}
|
|
|
|
})
|
2016-03-26 00:47:20 +01:00
|
|
|
```
|
|
|
|
|
2017-03-16 15:57:41 +01:00
|
|
|
See the documentation on [Numbers](/types/number) for more information on comparing two Numbers.
|