What is the output if this code? var a = 1/-infinity + 5%infinity; console.log(a); Ans = 5 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output if this code? var a = 1/-infinity + 5%infinity; console.log(a); Ans = 5

Please can someone explain to me how th answer is 5

3rd Oct 2019, 6:32 AM
Eta Pearl
2 Answers
+ 1
1 / Infinity is 0 and modulo operation returns the first number if it's smaller than the second one.
3rd Oct 2019, 8:05 AM
xyz$
+ 1
Gellert thanks
3rd Oct 2019, 8:14 AM
Eta Pearl