javascript

JavaScript to print Odd Numbers within a Range!

Let’s write a JavaScript program to print Odd Numbers within a given range.

First, to find an Odd number it is very simple, divide the number by 2 if the remainder value is not zero then it’s an Odd number.

Example if you give the start and end range from 10 to 20, the program has to print 11, 13, 15, 17, 19. So let’s write a simple snippet now.

The above script should print the values in the console as expected.

Let’s write a dynamic script with HTML to get the start and end range from the user and print the output on the browser.

Just go through the above script to understand it.

You can also see the demo of the above script:

demo

Related Posts

Leave a Reply