Find odd or even number with JavaScript problem solve

Find odd or even number with JavaScript problem solve

Make a program for find Odd or Even number with Javascript software.

Source code

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Even odd</title>
</head>
<body>
	<input type="text" id="valueSet" value="">
	<button onclick="myFunction()">Result</button>

<p id="v_print"> </p>

<script type="text/javascript">
function myFunction(){

	var x = document.getElementById("valueSet").value;

    for (i=1; i<=x; i++){

    	if(x%2 == 0){
    		result = " Even";
          }else{
    	   result ="Odd ";
         }
	    document.getElementById("v_print").innerHTML=x + " This number is " + result;
    }

}
</script>

</body>
</html>
Scroll to Top