Skip to content

Instantly share code, notes, and snippets.

@ross-u
Created October 2, 2019 13:08
Show Gist options
  • Save ross-u/1ffe89f6ff9bbe3138e69273a525de55 to your computer and use it in GitHub Desktop.
Save ross-u/1ffe89f6ff9bbe3138e69273a525de55 to your computer and use it in GitHub Desktop.

JS | Conditionals

Even/Odd - Exercise

Let’s write a for loop that will iterate from 0 to 20. For each iteration, it will check if the current number is even or odd, and print that on the screen. You will need the modulo (remainder) operator for this exercise. Make sure that number 0 is not printed.


Expected output:

1 is odd

2 is even

19 is odd

20 is even


for ( ; ; ) {

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment