answersLogoWhite

0


Best Answer

You can use the symbol % to see the remainder of the division problem. eg. document.write(11 % 3 + "") will display the number 2 since 3 goes into 11 three times with a remainder of 2.

So here's some sample code:

function oddEven(num){

if(num % 2 == 0){

return "even"

}

else{

return "odd"

}

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

You can use the following code to print a message containing the sum of even numbers between 1 and 10:


var sum = 0;for (var n=1; n<=10; n++) if (n / 2 Math.floor(n / 2)) sum += n;document.Write("The sum of even numbers from 1 to 10 is " + sum);


This answer is:
User Avatar

User Avatar

Wiki User

12y ago

In Javascript:

<script type="text/javascript" language="javaScript">

var arr= new Array(1,4,5,6,7,7,8,9,10);

var cnt=arr.length();

for(i=0;i<cnt;i++)

{

if(arr[i]%2 == 0)

alert('even');

else

alert('odd');

}

</script>

Logic to get even and odd number remain same in java.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Write and odd program, and add one to it.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write even odd program in for loop in java script?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can i write ducci's game in java script?

You just can't.


What program code is the easiest to learn?

Most likely java script


What is used to create large program on internet?

Java script


Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


How do you write javascript codes for website on a mac?

You can write java script code on any platform be it mac, linux, solaris or windows. All you need is a mac version of notepad, some html page where you insert your java script code and a web browser where you view the html page. All major browsers support java script coding and all you need to do is enable the Java Script support in browsers if it is not enabled already.


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


What is javadoc?

write a java program to display "Welcome Java" and list its execution steps.


How write new line program in java?

\n


What is java fx2.1.1?

Java script


Is Java script needed for Poptropica?

No, Java script is not needed to play poptropica.


What are good Java script codes?

depending on the intention of the javascript codes you wish to write. there is much you can do with javascript but the only way to find out what "good Java script codes" are is to explore what you want the Javascript to do on the page.