Java help

Associate
Joined
16 Mar 2004
Posts
1,931
Location
Oxford
I'm trying to find the average value of 2 numbers using Javascript, however I don't know where I'm going wrong.

Code:
<script language="JavaScript"
var 1stValue, 2ndValue, answer;
1stValue = window.prompt ('enternumber 1', ',','');
1stValue = parseFloat (1stValue);
2ndValue = window.prompt ('enter number 2', ',','');
2ndValue = parseFloat (2ndValue);
result = 1stValue + 2ndValue / 2;
document.write 'the average of' 1stValue 2ndValue ' is ' answer);
</script>

What am I doing wrong?
 
Thanks Moe, it works!

Sorry for the confusion earlier, I don't know what I was thinking about, must have been a late night (Java = JavaScript :rolleyes: )
 
Back
Top Bottom