From 8df55d5296ecb3ab3cb2dd4566833ead2ea2d4e2 Mon Sep 17 00:00:00 2001 From: Channeas Date: Fri, 21 Dec 2018 04:04:58 +0100 Subject: [PATCH] Wrote about operators and fixed a faulty example (#23950) --- guide/english/javascript/if-else-statement/index.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guide/english/javascript/if-else-statement/index.md b/guide/english/javascript/if-else-statement/index.md index 9fecb81449..c4685ef41d 100644 --- a/guide/english/javascript/if-else-statement/index.md +++ b/guide/english/javascript/if-else-statement/index.md @@ -15,6 +15,9 @@ if (condition) { } ``` +The conditions can be as simple as just checking booleans, but you can also check the value of variables using operators. One of the most commonly used operators is the equality operator, "==". It checks if two values are equal to each other. Note that there are two equal signs and not just one. This is because of the fact that one equal sign would set the first value to equal the second, not compare them. + +Some other common operators are the greater/smaller than operator (> and < respectively) and the not equal to operator (!=). Multiple `if...else` statements can be chained to create an `else if` clause. This specifies a new condition to test and can be repeated to test multiple conditions, checking until a true statement is presented to execute. @@ -64,8 +67,8 @@ const num = someCondition ? 1 : 2; ## Examples **Using** `if...else`: -```javascript +```javascript // If x is equal to 5, then the condition is TRUE. This results in z being set to 7 and q being set to 42. // If x does not equal to 5, then the condition is FALSE. This results in z being set to 19. if (x == 5) { @@ -74,7 +77,6 @@ if (x == 5) { } else { z = 19; } - ``` **Using** `else if`: