logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-04-2008, 01:55 AM   #1
ArmyWife0306
 
Join Date: Dec 2008
Posts: 1
Question Javascript using arrays

I need help to make a javasvript program that will take an array as input and calculate the square root of its element. This is what I have, but I cant figure out any more.
HTML Code:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Generated by AceHTM http://freeware.acehtml.com -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Using Arrays</title>
<script language="javascript">
 
<!-- hide script away from browsers
//define array and calculate sum of element squares
numArray = new Array (2, 5, 6, -3, 0, -7, 9, 4);
sumSquares = 0;
for (i=0; i<8; i++) {
sumSquares += numArray[i]*numArray[i];
}//for
 
//print results
document.write("The sum of the sqaures of these " + numArray.length + " numbers:<br />");
for (i=0; i<8; i++) {
document.write(numArray[i] + ", ");
}//for
document.write("is <h2>" + sumSquares + "</h2>");
-->
 
</script>
</head>
<body>
</body>
</html>

Last edited by davidj; 12-04-2008 at 06:44 AM..
ArmyWife0306 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:23 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com