PDA

View Full Version : javascript


harriersfan
03-08-2000, 22:41
wtf is wrong with my v. simple js:

<script language=javascript>
alert (a javascript to find the area of a circle)
var radius = prompt ("what is the radius of the circle?","don't enter units yet, just a number...")
var unit = prompt ("enter the units of the radius?","see why you din't need to enter units now?")

var area = 3.141592653589793(radius * radius)
alert ("the area of the circle is" +area+unit+"<sup>2</sup>")
</script>

schmoely
03-08-2000, 23:52
Hello mate - try this:

------------------------------------------------------------------

<SCRIPT LANGUAGE="JavaScript">

alert ("a javascript to find the area of a circle");

var radius = prompt ("what is the radius of the circle?","don't enter units yet, just a number...");
var unit = prompt ("enter the units of the radius?","see why you din't need to enter units now?");

var area = (3.141592653589793 * (radius * radius));
alert ("the area of the circle is " + area + unit);

</SCRIPT>

------------------------------------------------------------------

Few note things:

1) Don't forget the ';'

2) JavaScript (as with almost all other languages - I can only think of one that doesn't) needs to be told to do (PI * (r * r))... The statement (PI (r * r)) makes it drop its load!

3) Couldn't work out what the <SUP> business was about - but it has been WAAAAAAAAY too long since I looked at HTML, JavaScript and stuff like that!

harriersfan
04-08-2000, 18:32
superscript so that the it's cm^2 or whatever the unit is.

harriersrfan