I am writing an all-text Javascript game and I need debugging help. Could someone tell me the problem with this?
Here is a function in the beginning of the file. What it should do is see if "player.level" is 1. If so, it returns 10. Otherwise, it returns the triangle number equal to its level*100
(n+1)/2 is the formula for triangle numbers
function getExp()
{
if (player.level==1)
{
var exp=10
}else{
var exp=(50*player.level)*(player.level+1)
}
alert(exp)
return exp
}
When I call the function like this
alert(getExp())
the page refreshes.
Help?
Here is a function in the beginning of the file. What it should do is see if "player.level" is 1. If so, it returns 10. Otherwise, it returns the triangle number equal to its level*100
function getExp()
{
if (player.level==1)
{
var exp=10
}else{
var exp=(50*player.level)*(player.level+1)
}
alert(exp)
return exp
}
When I call the function like this
alert(getExp())
the page refreshes.
Help?