-2

I want to display numbers to words for example user enter 1 that display one inn angular

  • Hi, have you tried anything so far yourself? And for what range of numbers do you need to be converted? – Elydasian Apr 04 '19 at 06:14
  • 1
    Possible duplicate of [Convert digits into words with JavaScript](https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript) – wentjun Apr 04 '19 at 06:34

1 Answers1

0

Instead of you writing a whole bunch of code, here is a nifty little library that does it for you.

var converter = require('number-to-words');
converter.toWords(13); // => “thirteen”
converter.toWords(-3); // => “minus three”
converter.toWords(9007199254740992); // => “nine quadrillion, seven trillion, one hundred ninety-nine billion, two hundred fifty-four million, seven hundred forty thousand, nine hundred ninety-two”

Just install this library using

npm install number-to-words --save

Or the general idea is to use a loop backwards on a number and convert the numbers to ones, tens, hundreds, thousands and so on, till you reach the beginning and print your result.

AshTyson
  • 473
  • 7
  • 23