> Tutorial
Operators let you perform mathematical calculations or all kinds of data manipulation.
Here are the main operators:
+: Addition of two numbers-: Subtraction*: Multiplication/: Division%: Remainder of the division (modulo)==: Equality between two values, =`: Comparison of two numbers&&: "And" of two booleans||: "Or" of two booleans!: "Not" (inverts a boolean)=: Assigning a variable+=, -=, *= etc.: Operator combined with assigning a variableTo get the quotient of an integer division, use Math.floor(a / b).
In an expression with several operators, the operators follow the usual precedence rules, so * comes before +.
Example with different operators:
You can also use parentheses, as in: (5 + 7) * 2.
Besides the = operator, there are many assignment operators, such as +=, -=, *= etc., which combine a calculation and an assignment.
An example with *=, which performs a multiplication and stores the result in the same variable:
Our current healing condition makes us heal as soon as we've lost 1 life point. We can improve it by healing only if our life is
To display the value of a variable or an expression in the fight's actions, use Debug.log(). Example: Debug.log(me.maxLife * 0.75).
What is the result of the code 10 + (5 * 7) - 20 / 4?
40 25 18 -30
What is the value of x at the end of the code let x = 10 x *= 2 x += 5 x /= 5?
5 15 22 12
What is the result of the code (true && false) || (true && true)?
1 3 true false
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.