0% found this document useful (0 votes)
68 views1 page

JavaScript Loop Example Code

This document provides an example code using a for loop in JavaScript. The code prints out the numbers from 0 to 9, labeling each as odd or even depending on whether the number is divisible by 2. It contains HTML tags to define a web page with a script element containing the for loop code that writes each number and description to the document.

Uploaded by

Oseni Nojeem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views1 page

JavaScript Loop Example Code

This document provides an example code using a for loop in JavaScript. The code prints out the numbers from 0 to 9, labeling each as odd or even depending on whether the number is divisible by 2. It contains HTML tags to define a web page with a script element containing the for loop code that writes each number and description to the document.

Uploaded by

Oseni Nojeem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Example 2: Open your notepad and type the following lines of code.

At the end of this practice, you will practically see how loops work in JavaScript. <HTML> <HEAD> <TITLE>Testing JavaScript Loop Statement</TITLE> </HEAD>
90

<BODY> <PRE> A for loop that writes out the numbers from 0 through 9 and labels them as being odd or even. <SCRIPT Language="JavaScript"> <!-for (i=0; i < 10; i++) { if (i%2 != 0) [Link](i + " is odd") else [Link](i + " is even") } // --> </SCRIPT> </PRE> </BODY> </HTML>

2012-07-02

Huawei Proprietary - Restricted Distribution

Page1, Total1

You might also like