Finding a Remainder in JavaScript?

Finding a Remainder in JavaScript?
0

#1

Tell us what’s happening:

I just wonder whether there are variety of answers of this chapter or not.
The instructions ask us ‘Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.’ which means the remainder is 2.

So, it would be 2 % 3, 2 % 4, 2 % 5, 2 % 6, 2 % 7, 2 % 8, 2 % 9, 2 % 10, 2 % 11 …
or 20 % 18, 21 % 19… also leave the remainder which is 2.

So, there mustn’t be only one answer in this chapter, so you guys don’t have to be confused with many different answers.

Please let me know if my guess is wrong.

Thanks. Let’s coding guys.

Your code so far

// Only change code below this line

var remainder = 2 % 15;

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; InfoPath.2; .NET4.0C; .NET4.0E; MARKANYEPS#25115; rv:11.0) like Gecko.

Link to the challenge:


#2

Ha! Ha! You’re right, of course, it works too. But that’s really a limitation of the tests used. The instruction is meant to be taken literally: Use the % operator with 11 and 3.

Of course you can get the same result with a different operation but it’s not what you’re supposed to do. It’s a bit as if you were being asked to use the + operator on 4 and 5. Sure you could write var result = 6 + 3;, the answer would be 9 too but that’s not what is being asked.

That said it doesn’t matter. What matters is that you know there is a % operator and you know how to use it correctly. It will come in handy in the future and you will be the one deciding what numbers to apply it on.


#3

Thank you for your reply.

I get what you meant, but there is no instruction that says we have to use the % operatior with only 11 and 3. What I understood is that we have to find the reminder that equals to the remainder of 11 divided by 3 using the remainder (%) operator, which is 2. So, it’s not the test’s error and limitation I think. The test let us find many answers that remains 2 from the mathematical expressions. What do you think?


#4

Glad I came across this thread. The test accepting multiple different answers was kind of freaking me out there. :slight_smile:


#5

same here bro …