 # Hello, please take a look at this code snippet, does the -= means <= and the += , >=?

``````let price = 10.5;
let day = "Monday";

day === "Monday" ? price -= 1.5 : price += 1.5;
``````

You code is a version of the if gate.

`-=` and `+=` are both operators.

-= subtracts from a value and += adds to a value, they are both shortcuts to save typing time. To give an example, lets set up two values:

``````let number = 5;
let second_number = 7;
``````

Now the following two line are equivalent:

``````number = number + second_number;

number += second_number;
``````

If you are wondering how these apply to the if gate I suggest reviewing this lesson Ternary Operators

You can also see more about `-=` and `+=` at:
Subtraction operators

Please remember that you can use documentation like MDN to find out how to use elements such as these. This will help you grow as a coder. Happy coding @wilfriedpiwo35277140!! 1 Like

Hello @wilfriedpiwo35277140, as @8-bitgaming explained, the `-=` and `+=` are addition and subtraction operators. (There is also `*=` and `/=` which are for multiplication and division respectively). What about `>=` and `<=`? Well, these are a form of equality operators, just like `===`, `>`, `<`, except they do different things:

``````=== //Checks if two things are equal:
if (1 ==== 1) {
console.log("1");//"1" appears
}

> //Checks if the left object is greater than the right object:
if (2 > 1){
console.log("2");//"2" appears, as it is greater than 1
}

< //Opposite as the one above (less than):
if (1 < 2){
console.log("1")//"1" appears as it is less than 2
}

<= //Less than or equal to; checks in the left object is less than, or
//equal to, the object on the right:
if (1 <= 2){
console.log("2");//2 appears because 1 is less than or equal to two
}
if (2 <= 2){
console.log("2");//"2" also appears, because two is equal to two
//(less than OR equal to)

>= //Same as above, except greater than or equal to:
if (3 >= 2){
console.log("2");//2 appears because 3 is greater than or equal to two
}
if (3 >= 3){
console.log("2");//"2" also appears, because three is equal to three
//(greater than OR equal to)
``````

I hope this helps!
Happy coding!

1 Like

hi, thanks for your response. i remenber learned this in the ternary operators course. 1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.