highspeed4eva
04-22-2005, 02:33 PM
Hello,
I have to write a javascript program that uses a function which takes an array as input and calculates the square roots of its elements. I am as beginner as a beginner can get and this is my homework. I am stumped. This is what I have come pup with:
<?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">
<!-- Created on: 4/22/2005 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Function Using array as input</title>
<script language="javascript">
function squares(numArray){math.sqrt=0;len=numArray.length;for(i=0;i<len;i++){math.sqrt+=math.sqrt(numArray);}
numArray = new Array (36,49,81); math.sqrt;for (i=0;i<3;i++){math.sqrt +=math.sqrt(numArray[i]);}
document.write("The square roots of these" + numArray.length + "numbers<br />");for (i=0;i<3;i++){ document.write (numArray[i]+",");}document.write("is<h2>"+math.sqrt+"</h2>");}</script>
</head>
<body>
</body>
</html>
What am I doing wrong? Any help will be greatly appreciated.
I have to write a javascript program that uses a function which takes an array as input and calculates the square roots of its elements. I am as beginner as a beginner can get and this is my homework. I am stumped. This is what I have come pup with:
<?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">
<!-- Created on: 4/22/2005 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Function Using array as input</title>
<script language="javascript">
function squares(numArray){math.sqrt=0;len=numArray.length;for(i=0;i<len;i++){math.sqrt+=math.sqrt(numArray);}
numArray = new Array (36,49,81); math.sqrt;for (i=0;i<3;i++){math.sqrt +=math.sqrt(numArray[i]);}
document.write("The square roots of these" + numArray.length + "numbers<br />");for (i=0;i<3;i++){ document.write (numArray[i]+",");}document.write("is<h2>"+math.sqrt+"</h2>");}</script>
</head>
<body>
</body>
</html>
What am I doing wrong? Any help will be greatly appreciated.