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

Thread Tools Display Modes
Old 12-04-2008, 01:55 AM   #1
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"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Generated by AceHTM http://freeware.acehtml.com -->
<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];
//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] + ", ");
document.write("is <h2>" + sumSquares + "</h2>");

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

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