0% found this document useful (0 votes)
11 views2 pages

Loop

The document contains a JavaScript code that demonstrates the use of a for loop to create headings from 1 to 6 with the text 'Hello'. It also displays mathematical constants like Math.PI and LN2, and showcases various array methods including accessing elements, converting to a string, joining elements with a separator, and reversing the array. The code outputs the results directly to the HTML document.

Uploaded by

ahsanhasnain2834
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Loop

The document contains a JavaScript code that demonstrates the use of a for loop to create headings from 1 to 6 with the text 'Hello'. It also displays mathematical constants like Math.PI and LN2, and showcases various array methods including accessing elements, converting to a string, joining elements with a separator, and reversing the array. The code outputs the results directly to the HTML document.

Uploaded by

ahsanhasnain2834
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

<html>

<head><title>for loop</title></head>

<body>

<script language="JavaScript">

for(i=1;i<7;i++)document.write("<H"+i+">Hello"+i+"</h"+i+">");

</script>

<script language="JavaScript">

document.write("Math.PI: "+Math.PI+"<p>")

document.write("LN2: "+Math.LN2+"<p>")

</script>

<script language="JavaScript">

array=[0,1,2,3,4,5,6,7,8,9];

document.write("use array[digit number] for call nth value: "+array[2]+"<p>");

document.write("use array.toString() to return values separated by comma


"+array.toString()+"<p>")

document.write("use array.join to replace distance between values "+array.join('-')+"<p>")

document.write("use array.reverse to reverse "+array.reverse()+"<p>")


</script>

</body>

</html>

You might also like