0

I was wondering if there is already any javascript function to convert a int value to its string value. I am sorry but I don't the exact term to use it and hence please follow below examples:

if I pass 2, it should return "two" if I pass 11, it should return "eleven"

I assume there would be a limit and my requirement is to find those number values upto 3 digits (0 - 999)

I want to save time by not creating a mapping string set manually.

Zakir Sayed
  • 200
  • 2
  • 12

3 Answers3

1

There's no inbuilt API for this in Javascript. However, writing your own function shouldn't be that difficult, since once you get past the teens, there is a fixed pattern (twenty one, thirty one, forty one etc.)

Ayush
  • 41,754
  • 51
  • 164
  • 239
1

Take a look at that, it can convert numbers up to 1000

Moritz Mahringer
  • 1,240
  • 16
  • 28
1

Unfortunately there is nothing existing that will allow you to do this, but there are plenty of solutions out there. See this link for a bunch of examples: JavaScript numbers to Words

Community
  • 1
  • 1
mkowalski
  • 51
  • 2