-
Javascript help
Hello all
i need some help with this program that i'm trying to make
i'm new at this so it's probably a dumb mistake but i can't find it
function Bereken_onclick()
{
horizontalspeed = prompt("Give the horizontal speed in meters per second","")
height = prompt("Give the height of the plane in meters.","")
verticalspeed = (height*2*9.81)^0.5
distance = (horizontalspeed*verticalspeed)/9.81
tg = height / distance
arctangens = Atn(tg)
angle = 60*arctangens
document.write("The pilot has to drop the bomb when he sees the target under an angle of " + angle + " degrees.")
}
and the error it gives:
Line : 17
char : 1
code : 0
error : Object expected
pls help
-
Senior Member
Hi,
A couple of possible problems - I don't think there is a ^ operator in Javascript - Instead you can use,
Math.pow(height * 2 * 9.81, 0.5);
or in this case,
Math.sqrt(height * 2 * 9.81);
The other thing was is the function Atn defined anywhere?
You could try using
Math.atan2(tg);
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|