Is this a good example of a While-loop being used on a website?


#1

As codecademy keeps interpreting my answer as invalid, "Oop! Try again,"
it will therefore keep addressing me with that same message as long as my answer continues to be wrong.
Mean while, I'm given as many chances as I need to get the answer right.
Is this a good example of a While-loop?


#2

Yes, that is just the sort of thing that you can use while loops for. I can't say for sure if that is what Codecademy is using for that particular exercise, but the user experience is the same.


#3

Thank you :grinning: Also, I'm still not able to understand Javascript Modulos and the role they play in Javascript. Though, I do understand the math associated with the them. Yet, I don't understand why programmers use them.
Are they used for financial purposes?
Or are modulos just another way to write an (if else) statement?:
if(10%2===0){
Console.log("The 1st number is even.");}
else{
Console.log("The 1st number is odd");}


#4

Even though it is the same symbol as percentage, it is not related. Modulo is just the remainder of a division operation.

No, that isn't what they are for. In the case that you have shown, the modulo operator is used in that particular if condition to find out if the number has a reminder when divided by 2 -- which just happens to be the definition of a number is even or odd.

These have some other examples of when you can use modulo to get something done: