Closed Thread Icon

Topic awaiting preservation: toString problem.... Pages that link to <a href="https://ozoneasylum.com/backlink?for=8684" title="Pages that link to Topic awaiting preservation: toString problem...." rel="nofollow" >Topic awaiting preservation: toString problem....\

 
Author Thread
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-02-2003 04:09

hi, people. How are you today?
Well, it is Queen's birthday so that school is off today.
I am spending time practicing JavaScript as usual.

Well, I got an problem.
What I want to do is to show 0 to 16 using binary and Hex on the screen by Javascript.
It is as simple as that. But somereason, doesn't work.

What I did is below:

code:
<html>
<head>
<title>Binary to Hex</title>
</head>
<body>
<pre>
<script type="text/javascript">
for(x=0; x<16; x++){
document.write(Binary: ", x.toString(2), " Hexadeciaml: ", x.toString(16), "<br />")
}
</script>
</pre>
</body>
</html>



Error massage said that expected ")" on line 9. But I see there is ( ) both of them.
Hmm.....please help!

Hiroki Kozai

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 06-02-2003 06:05

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-02-2003 07:23

Many thanks for your reply.
I appreciate that.
But still doesn't work.
that's all right. I will figure out.

In my book and a couple of people said:

quote:
JavaScript is loose type programming language so that missing ; is quite acceptable.



Even a book from libary always omit it.

Hiroki Kozai

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-02-2003 07:29

document.write only takes one argument: a single string. If you need to concatenate multiple strings, use plus (+), not commas (,).

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-02-2003 08:04

Thank you very much,Slime.
It worked perfectly.
Cya.

Hiroki Kozai

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 06-02-2003 08:52

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

quisja
Paranoid (IV) Inmate

From: everywhere
Insane since: Jun 2002

posted posted 06-02-2003 10:06

And you're missing a ' " ' after your first ' ( ' .

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-03-2003 00:33

Hi, guys.
Yes, I found missing " ! after I read Slime's thread.
Now it is all right.
Many many thanks a lot.
Cya.

Hiroki Kozai

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-03-2003 01:58

InI: yes, I remember that there is a function in JavaScript which takes a base as its argument and produces a string representation of a given number in that base, and I do believe it was the toString method.

[edit: yeah, try (3).toString(2) ]

[This message has been edited by Slime (edited 06-03-2003).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 06-03-2003 09:06

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 06-04-2003 11:49

I think the only problem was the missing ' " ' because you can do things like

code:
document.write("hey", " there") // "hey there"



Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-04-2003 17:14

Ah.

« BackwardsOnwards »

Show Forum Drop Down Menu