+ 2
What is -1%3 in js?
Line 17 of js is what concerns me. https://code.sololearn.com/Wc4oo2HhfICK/?ref=app
15 Answers
+ 4
Oh the answer is -1 because % is a remainder operator not modulo and they treat negative numbers differently.
+ 9
Sharmin Rumpa if u will ask reason why 2*4 = 8 i cannot explain this 🤣🤣😂 our mathematician gave this rule and we following their rules
+ 8
Sharmin Rumpa wht u have doubt
+ 8
Sharmin Rumpa Remainder will be -1 simple way to remember this if numerator is small than denominator then answer will be numerator
+ 8
Sharmin Rumpa(Dm ✉ = ❌) yes MBW it is BMW not MBW 🤣🤣😂
+ 7
I dont know about javascript but in c, cpp or java output will be -1
+ 2
But i think % is not working that way in the above code.
+ 1
🐍Sizuna 🐉 Its just typing mistake. And I just declare array it's doesn't matter BMW or MBW.
+ 1
🐍Sizuna 🐉 😯 😐 👀 I know
0
🐍Sizuna 🐉 In js also result is -1, but I don't understand why???
0
🐍Sizuna 🐉 why -1 result? I know it's result -1 but I don't know how or I don't know logic.
0
🐍Sizuna 🐉 I know & I remember this way. I want to know why? Why numerator is result.
0
🐍Sizuna 🐉 😁😁 I don't ask that way.
It's like. . . . Suppose
Var car = ["Saab", "Volvo", "BMW"];
Car[1] = "Volvo"; Cause index start from 0.