Link to home
Start Free TrialLog in
Avatar of Alk
Alk

asked on

Style issue

I want to write x to be squared, ie x2 but the 2 is to the power of x.
how do i get the 2 like that??

Avatar of reubenbell
reubenbell

I dont get it do you mean.

<script>
var x = 2;
document.write("square of x: " + parseFloat((x * x)))

var y = Math.pow(x, 2);
document.write("y = xpower of 2: " + y)

//i think you might want this
var pow = 3; //power of newx
var newx = 5;

var curnum = newx;
for (var i=0;i<(pow+1);i++){
   curnum = curnum * curnum;
}
document.write(newx + " to the power of " + pow + " is " + curnum)
</script>
ASKER CERTIFIED SOLUTION
Avatar of Indurain
Indurain

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
lol, thats what he ****ing meant.

sorry,
!!!
RB

(should have got points for effort tho, hehe)
Avatar of Alk

ASKER

Excellent
Sorry for the confusion!!