Odd or even

 AIM: Write a program to check if a number is odd or even.

Source Code:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<input type="button" onclick="odd()" value="click here">

<script>

function odd() {

var n= parseInt(prompt("number: "));

if(n%2!=0){

document.writeln("this is an odd number");}

else{

document.writeln("this is an even number");}}

</script>

</body>

</html>

Comments

Popular posts from this blog

Calculate Factorial using While loop in JavaScript.

Calculator

Simple calculator