Wanting to change numbers to text - not what you think

I was stuck how to ask the question.

Say my payload is 09:14:10 (text)

I want to convert it to words.

So it would become
zero nine fourteen ten

I think I know how to do it, but it is a lot of typing.
Only because I don't want to re-invent the wheel, I thought I would ask.

This is what I've bashed together ITMT.

There are specific things as this is one of 3 nodes that do this.
(Maybe I should lean how to use the link call things.)

[{"id":"5af44b35e506449f","type":"function","z":"fe5670ff.ea94e","name":"words","func":"var value = {\n    0:\"zero\",\n    1:\"zero one\",\n    2:\"zero two\",\n    3:\"zero three\",\n    4:\"zero four\",\n    5:\"zero five\",\n    6:\"zero six\",\n    7:\"zero seven\",\n    8:\"zero eight\",\n    9:\"zero nine\",\n    10:\"ten\",\n    11:\"eleven\",\n    12:\"twelve\",\n    13:\"thirteen\",\n    14:\"forteen\",\n    15:\"fifteen\",\n    16:\"sixteen\",\n    17:\"seventeen\",\n    18:\"eighteen\",\n    19:\"nineteen\",\n    20:\"twenty\",\n    21:\"twenty one\",\n    22:\"twenty two\",\n    23:\"twenty three\",\n    24:\"twenty four\",\n    25:\"twenty five\",\n    26:\"twnety six\",\n    27:\"twnety seven\",\n    28:\"twenty eight\",\n    29:\"twnety nine\",\n    30:\"thirty\",\n    31:\"thirty one\",\n    32:\"thirty two\",\n    33:\"thirty three\",\n    34:\"thirty four\",\n    35:\"thirty five\",\n    36:\"thirty six\",\n    37:\"thirty even\",\n    38:\"thirty eight\",\n    39:\"tirty nine\",\n    40:\"forty\",\n    41:\"forty one\",\n    42:\"forty two\",\n    43:\"forty three\",\n    44:\"forty four\",\n    45:\"forty five\",\n    46:\"forty six\",\n    47:\"forty seven\",\n    48:\"forty eight\",\n    49:\"forty nine\",\n    50:\"fifty\",\n    51:\"fifty one\",\n    52:\"fifty two\",\n    53:\"fifty three\",\n    54:\"fifty four\",\n    55:\"fifty five\",\n    56:\"fifty six\",\n    57:\"fifty seven\",\n    58:\"fity eight\",\n    59:\"fifty nine\",\n};\nconst foo = parseInt(msg.payload);\nconst words = value[foo];\nmsg.payload = words;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":580,"wires":[["33968b181cbc74c6","a96bc82be3395e38"]]}]

Have you tested that? There is another twnety, a tirty and a fity.

1 Like

Sorry Colin,

Have I tested which?

Colin is referring to the multiple spelling mistakes Andrew


1 Like

You posted some code, I asked if you had tested it.


Yes, it works.

Maybe not all the words were spelt correctly.

I try to touch type and sometimes the fingers and keyboard are on different pages to where things are.

So I made a few mistakes. (I'm good at that.) :wink:

Yeah, finger miscoordination when I am trying to touch type.

(And I can't spell) :wink:

I'll go back and edit it now.

How did it pronounce twnety?

I honestly can't say.

I wrote it and tested it with the time as it was at time of testing.

Luckily that didn't happen so I can't say. But probably funnily. :wink:
Maybe like someone who had a bit too much to drink? :wink:

Testing software implies checking, as far as practical, all the possible routes through. You had not tested all the values so you had not properly tested it.


It is part of the learning curve. Of which I admit I am very much at the bottom/start.

It was more to get it out there as I had spent ...... 4 hours making it.
(Shame on me for not properly testing it, and wanting/thinking it is good for anyone anyway.)
It was a bit of a high I was on.

Sorry, I'm babbling now.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.