highspeed4eva
04-23-2007, 02:02 PM
:confused: I have a homework assignment and I am officialy stumped any help will be greatly appreciated. This is what the assignment asks:
Write a JavaScript program that uses a function which takes an array as input and calculates the square roots of its elements.
I have written the following 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>Chpter 20 hw20.4</title>
<script language="javascript">
function squares (numArray) {
len = numArray.length;
for (i=0; i<len; i++); {
document.write("The square root of these" + len + "numbers:<br /">
for(i=0; i<len; i++) {
document.write(numArray[i] + ",");
}
document.write ("are <h2>" + squares + "</h2>");
}
numArray = new Array (2, 4, 6, 8, 10);
squares(numArray);
</script>
</head>
<body>
</body>
</html>
Write a JavaScript program that uses a function which takes an array as input and calculates the square roots of its elements.
I have written the following 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>Chpter 20 hw20.4</title>
<script language="javascript">
function squares (numArray) {
len = numArray.length;
for (i=0; i<len; i++); {
document.write("The square root of these" + len + "numbers:<br /">
for(i=0; i<len; i++) {
document.write(numArray[i] + ",");
}
document.write ("are <h2>" + squares + "</h2>");
}
numArray = new Array (2, 4, 6, 8, 10);
squares(numArray);
</script>
</head>
<body>
</body>
</html>