+ 2
What is -1%3 in js?
Line 17 of js is what concerns me. https://code.sololearn.com/Wc4oo2HhfICK/?ref=app
13 RĂ©ponses
+ 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.