← Trail· Lesson 3 of 10
See this lesson in JavaScript →
Operators and expressions
Do math, compare values and combine typed boolean conditions with && and ||.

An expression produces a value: 3 * 10 is a number, 30 >= 18 is a boolean. Use + - * /, % for the remainder, ===/!== for strict equality and > < >= <= to compare.
TypeScript helps here: 20 === '20' is flagged, because a number can never equal a string. Plain JavaScript would just return false silently.
&& means AND, || means OR. The party rule: at least 18 AND (invitation OR companion): idade >= 18 && (temConvite || acompanhado). The result is a boolean, the function’s return type.
Try it
Change the quantity, price and balance. total has no annotation: TypeScript infers number.
Execute o código para ver a saída aqui.Exercise
Complete podeEntrar(idade: number, temConvite: boolean, acompanhado: boolean): boolean. The starter forgets the companion and excludes exactly 18. Fix the expression after return using >=, &&, || and parentheses. Feedback is in Portuguese.
Execute o código para ver a saída aqui.Edite o TypeScript e clique em Verificar.
Next step
Next, these boolean expressions choose paths with if/else, switch and literal types.