For Loop:-
JavaScript में For लूप का उपयोग तब किया जाता है, जब आपको पहले से ही पता होता हैं की स्क्रिप्ट कितनी बार चलनी चाहिए। JavaScript Program मे कोई ऐसा Statement है या Block of Statements है जिसे आप Multiple Times Execute कराना चाहते है तो इस Situation मे आप For Loop का उपयोग कर सकते है। For Loop मे तीन Expressions उपयोग किये जाते है, Initialization Expression, Condition Expression और Update Expression. इस लूप को Entry Controlled Loop भी कहा जाता है।
Syntax:-
<script>
for(initialize ; test ; increment/decrement)
{
statement(s);
}
</script>
Questions:- 1. Wap to print the odd number between 1 to 50.
2. Wap to check a number is prime or not.
For Loop:-
For loops in JavaScript are used when you already know how many times the script should run. If there is any statement or block of statements in JavaScript program which you want to execute multiple times, then in this situation you can use For Loop. Three expressions are used in For Loop, Initialization Expression, Condition Expression and Update Expression. This loop is also called Entry Controlled Loop.
Syntax:-
<script>
for(initialize ; test ; increment/decrement)
{
statement(s);
}
</script>
Questions:- 1. Wap to print the odd number between 1 to 50.
2. Wap to check a number is prime or not.