Operators in JavaScript | SoloLearn: Learn to code for FREE!


Operators in JavaScript

I am a little confused by this code could someone be kind enough to explain? The answer is 36, but I don’t understand why. var x = 326; var prod = 1; while (x > 0) { prod *= x % 10; x = (x - x % 10) / 10; } document.write (prod);

4/23/2018 1:48:53 AM


5 Answers

New Answer


I don't know how familiar you are with this stuff so here is a very detailed answer. Open the code and go to the JS tab. Read the comments https://code.sololearn.com/WMLBCm2P3PpA/?ref=app


☺ Happy to help! And the forum is awesome indeed!


When it comes to loops you must keep going back until the condition becomes false


That is an AWESOME explanation. I got as far as 32 but wasn’t going back each time. Thank you for the very cool and thoughtful response. I get it now. The forum is the best.


Of course. Some times I make things more complicated than they are. I need another perspective to remind me... loops loop. Lol thank you, cyk.