usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code for Listing Odd Numbers in JavaScript




What are Odd Numbers?

Odd numbers are numbers that are not divisible by 2.

They include:

1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, ...

Thankfully, odd numbers complement even numbers. So our JavaScript code for listing odd numbers is almost same as the one for even numbers.

Create a new file; On Notepad++: File, New.
Call it OddNumbers.html.
Type out the adjoining JavaScript code for listing odd numbers.




Code for Odd Number List with Input in JavaScript

For a little more flexibility, let's add an input form.



We have used a function here.
A function is a chunk of code that is executed when it is called upon, such as when an event occurs.










<< PreviousNext >>