+ 2

What is -1%3 in js?

Line 17 of js is what concerns me. https://code.sololearn.com/Wc4oo2HhfICK/?ref=app

7th Jul 2020, 4:10 AM
Sameer Crestha
Sameer Crestha - avatar
13 RĂ©ponses
+ 4
Oh the answer is -1 because % is a remainder operator not modulo and they treat negative numbers differently.
7th Jul 2020, 4:58 AM
Sameer Crestha
Sameer Crestha - avatar
+ 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
8th Jul 2020, 7:25 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 8
Sharmin Rumpa wht u have doubt
8th Jul 2020, 7:16 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 8
Sharmin Rumpa Remainder will be -1 simple way to remember this if numerator is small than denominator then answer will be numerator
8th Jul 2020, 7:19 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 8
Sharmin Rumpa(Dm ✉ = ❌) yes MBW it is BMW not MBW đŸ€ŁđŸ€ŁđŸ˜‚
8th Jul 2020, 7:35 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 7
I dont know about javascript but in c, cpp or java output will be -1
8th Jul 2020, 6:54 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
But i think % is not working that way in the above code.
7th Jul 2020, 4:42 AM
Sameer Crestha
Sameer Crestha - avatar
+ 1
🐍Sizuna 🐉 Its just typing mistake. And I just declare array it's doesn't matter BMW or MBW.
8th Jul 2020, 7:38 PM
Sharmin Rumpa
Sharmin Rumpa - avatar
+ 1
🐍Sizuna 🐉 😯 😐 👀 I know
8th Jul 2020, 7:40 PM
Sharmin Rumpa
Sharmin Rumpa - avatar
0
🐍Sizuna 🐉 In js also result is -1, but I don't understand why???
8th Jul 2020, 7:15 PM
Sharmin Rumpa
Sharmin Rumpa - avatar
0
🐍Sizuna 🐉 why -1 result? I know it's result -1 but I don't know how or I don't know logic.
8th Jul 2020, 7:18 PM
Sharmin Rumpa
Sharmin Rumpa - avatar
0
🐍Sizuna 🐉 I know & I remember this way. I want to know why? Why numerator is result.
8th Jul 2020, 7:22 PM
Sharmin Rumpa
Sharmin Rumpa - avatar
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.
8th Jul 2020, 7:33 PM
Sharmin Rumpa
Sharmin Rumpa - avatar