hello guys..... i need a help about javascript

how to convert number (ex. 1) ----> to a word (ex, one)?

here it is.... ....if i will input a number like 20 it will then displayed a word twenty..
(the numerical 20 --------> become a word "twenty")


thankz in advance

Member Avatar for stbuchok

you would need to create a data dictionary.

var numbers = [];

numbers[0] = 'zero';
numbers[1] = 'one';
numbers[2] = 'two';
numbers[3] = 'three';
numbers[4] = 'four';
...

Have fun with that.

you would need to create a data dictionary.

var numbers = [];

numbers[0] = 'zero';
numbers[1] = 'one';
numbers[2] = 'two';
numbers[3] = 'three';
numbers[4] = 'four';
...

Have fun with that.

^^ thankz with that sir but what if i input 1,000,000 or above?
do i manually make a data dictionary up to million or beyond? or there is a code that do
all the conversion?

Member Avatar for stbuchok

There is no code to do the conversion. You could make an algorithm that could reduce a bit of the work, but you are kinda stuck my friend. You can try googling but I've never seen it before (beyond a hundred or so).

Member Avatar for stbuchok

I stand corrected, nice link.

uhmm.... can u teach me how to set up that in html?... have 1 button and 2 textbox (1 textbox is where u input a number then the 2nd is to display the result) thankzz so much^^

Is that not exactly the same as the demo?

Airshow

Is that not exactly the same as the demo?

Airshow

i mean... just set up this in html...and send me the ready made of this coz im just starting javascript ^^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.