Finding a Remainder in JavaScript help

Finding a Remainder in JavaScript help
0.0 0

#1

Tell us what’s happening:

Your code so far


// Only change code below this line

var remainder = 2;
11 % 3 = 1 (11 is odd)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript


#2

You did not ask a question when you posted your topic, but I assume you are wondering why your code does not work.

The instructions state “Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.”

All you have done is assigned the value 2 to the variable named remainder and then wrote 11 % 3 = 1 (11 is odd) on the second line which does nothing but cause an error.

You seem to understand how to assign values to variables, but you need to understand you can assign expressions to variables also. 11 % 3 is an expression which evaluates to 2, so you can simply assign the expression 11 % 3 to the variable named remainder on the first line and delete the 2nd line, because that does nothing except error out.