Click to See Complete Forum and Search --> : New to Javascript: HELP PLEASE!!!!!!!!!!!!!!!!


danbnl
09-12-2004, 10:27 PM
Im new to javascript and i just started learning it in class and i can't figure out whats wrong with my code. Its suppose to find the average, sum, product, smallest number and largest.
could anyone help me,

THANKS


<HEAD>
<TITLE>LAB 4 PART 3</TITLE>

<SCRIPT LANGUAGE="JavaScript">
var firstnumber,
secondnumber,
thirdnumber;

firstnumber = window.prompt("enter 1st integer","0");

secondnumber = window.prompt("enter 2nd integer","0");

thirdnumber = window.prompt("enter 3rd integer","0");

numberone = parseInt(firstnumber);

numbertwo = parseInt(secondnumber);

numberthree = parseInt(thirdnumber);

sum = numberone+numbertwo+numberthree;

average = sum/3;

product = numberone*numbertwo*numberthree;

if(numberone > numbertwo)
large = numberone;
else large = numbertwo;

if(numberthree > large)
large = numberthree;

if(numberone < numbertwo)
small = numberone;
else small = numbertwo;


if(numberthree < small)
small = numberthree;

window.alert("the product is"+product+"the average is"+average+"the largest number is"
+large+"the smallest number is"+small+");

</script>
</HEAD>
<BODY></BODY>
</HTML>

javaNoobie
09-12-2004, 10:46 PM
remove the following bolded partwindow.alert("the product is"+product+"the average is"+average+"the largest number is"
+large+"the smallest number is"+small+");

Jeff Mott
09-12-2004, 10:47 PM
Check the quotes on your alert line.

Kor
09-13-2004, 03:44 AM
and (even this is not the reason for your error) probably is a good ideea to use the formal syntax in the future, with all the brackets, especially if you are a begginer:

if(condition)
{
statement line1;
statement line2;
}

else
{
statement;
}