pxt-calliope/docs/blocks/logic/boolean.md
Peli de Halleux fb5bb396e1 more migration to common docs (#370)
* more migration to common docs

* refactoring js

* removed duplicate docs

* migrating more docs

* more refactoring

* migrated browsers page

* updated summary
2017-03-14 12:07:17 -07:00

745 B

@extends

#examples

Example: AND operator

This example turns on LED 3 , 3, if LEDs 1 , 1 and 2 , 2 are both on:

if (led.point(1,1) && led.point(2,2)) {
   led.plot(3,3)
}

Example: Comparisons of numbers and strings

When you compare two Numbers, you get a Boolean value, such as the comparison x < 5 in the code below:

input.onButtonPressed(Button.A, () => {
    let x = Math.random(5)
    if(x < 5) {
    basic.showString("low");
    } else { 
    basic.showString("high");
    }
})

See the documentation on Numbers for more information on comparing two Numbers. You can also compare strings using the equals function.