Turning a number to superscript

D

dalei

The following code does not work. Can anyone help with modifying it?

<script type='text/javascript'>

function super2 ()
{
var theNum = prompt ('Please enter a number: ', ' ');
document.write ('Its superscript is: ' + <sup>theNum</sup>);
}

super2 ();
</script>

Thanks.
 
I

Ivo

"dalei" wrote
<script type='text/javascript'>

function super2 ()
{
var theNum = prompt ('Please enter a number: ', ' ');
document.write ('Its superscript is: ' + <sup>theNum</sup>);
}

super2 ();
</script>

Did you mean
document.write ( 'Its superscript is: <sup>' + theNum + '</sup>' );

If not, let us know.
hth
ivo
 
R

Robert

Ivo said:
"dalei" wrote



Did you mean
document.write ( 'Its superscript is: <sup>' + theNum + '</sup>' );

Or this

document.write ('Its superscript is: ' + theNum.sup());
 
R

Robi

dalei wrote in message news:[email protected]...
Wondering why this does not work. It would be more preferred for
simplicity.

since when does "turning a number to superscript" not work?

or did you forget to quote what you're replying to?

whazzup?
 
D

dalei

Sorry. I referred following code:

document.write ('Its superscript is: ' + theNum.sup());
 
L

Lee

dalei said:
Sorry. I referred following code:

document.write ('Its superscript is: ' + theNum.sup());
Ok, and now what was that a reference to?

Notice that everybody who has responded to you has included enough
of the previous post to be able to understand what they are talking
about, without having to trace back through old posts, which may
have already expired from the system.
 
R

Robert

The following code does not work. Can anyone help with modifying it?
Wondering why this does not work.

No idea why it would no work. It works fine for me. Which part does not
work? The writing to a document or putting the sup tag around the string?

Ohh hmm, maybe because it think it is a number? Didn't try that.
What about:
document.write ('Its superscript is: ' + theNum.toString().sup());
or:
var theNum = prompt('Please enter a number: ', ' ').toString();
document.write ('Its superscript is: ' + theNum.sup());

Anyway, just wanted to say that string objects have a sup method you
might like to use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top