basic HTML java script problem?

  • Thread starter Thread starter Axolotl
  • Start date Start date
A

Axolotl

Guest
why does this code not work correctly?
hopefully by reading it you will get the idea of what it is supposed to do (it is very basic java)

<html>
<SCRIPT lANGAUGE= "JavaScript">
//inputting data, using variables and doing arithmetic
var name1, name2, age1, age2, averageAge;
name1 = prompt("What Is Your First Name?","Steve");
age1 = parselnt(prompt("What Is This Age?","21"));
name2 = prompt("What Is Second Name?","Steve");
age2 = parselnt(prompt("What Is This Age?","21"));
averageAge = (age1+age2)/2
document.write("average age of "+ name1 +"and"+name2);
document.write("is" + averageAge);
alert("Hopefully You Know The Average Age Of "+ name1 +"and "+ name2 +" now!!");
</SCRIPT>
</html>
 
Change this line:
<SCRIPT lANGAUGE= "JavaScript">
To this one:
<script language= "javascript">

And this one:
</SCRIPT>
To this:
</script>

And I suggest not to use CAPS when you write html code.
Have fun!
 
Change this line:
<SCRIPT lANGAUGE= "JavaScript">
To this one:
<script language= "javascript">

And this one:
</SCRIPT>
To this:
</script>

And I suggest not to use CAPS when you write html code.
Have fun!
 
parseint needs to be parseInt (with a capital i, not lowercase L)

Your uppercase i is really a lowercase L. It has to be an uppercase i.

(spelling lANGAUGE like that wouldn't matter to a browser)
 
Back
Top