+ 1
Is it me or Javascript doesn't accept negative number.
Hi there, I tried to make a code that increment or decerement the value of a variable (inicialValue) while it isn't equal to a certain value (valueToReach) Everything smooth when trying it on positive numbers. However, when trying on negative number, my entire code just dont work anymore (even trying on positive number again) I posted my code so that someone may check it and tell me if there is something wrong or it is a SOLOLEARN problem. https://code.sololearn.com/WlJ65iR58qZq/?ref=app
3 Answers
+ 3
Master
It is working but do while loop is going till infinite. That's why it is not showing anything.
inicialValue will be always greater than valueToReach (-10) so you need to break your loop at some point.
See I have changed little bit and it worked well.
https://code.sololearn.com/WIL8Rly2GXbd/?ref=app
+ 1
Hi I Am Groot !
Thanks for answering. The do-while of javascript is actually very diferent from the repeat-while of swift.
But there is a problem. In the code you introduced the value manually, so when I replace 10 by "valueToReach" it loop forever.
PS: I'm actually learning Javascript because we are learning it at school, but if I had to choose I would keep going with Swift XD