javascript - Math.pow calculations ground and power -
i want create piece of code math.pow
for instance, if put ground number 2 , power level 6
want result count 0 6.
2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
this have: (on jsfiddle)
function callpow(){ var val= document.getelementbyid("txt").value; var power= document.getelementbyid("txt2").value; alert(math.pow(val,power)); }
all need loop count specified power , alert each time:
function callpow(){ var val= document.getelementbyid("txt").value; var power= document.getelementbyid("txt2").value; for(i=0; i<= power; i++){ alert(val+' ^ '+i+' = '+math.pow(val,i)); } }
Comments
Post a Comment