How can you cast a simple spell in Node.js ?
Last Updated :
29 Nov, 2022
Node.js is a cross-platform, open-source back-end JavaScript runtime environment that uses the V8 engine to execute JavaScript code outside of a web browser. Node.js allows developers to utilize JavaScript to create command-line tools and server-side scripting, which involves running scripts on the server before sending the page to the user’s browser.
In this article, we are going to see how we can use the spelljs library in node.js.
SpellJS, as described on its npm page, is “A simple JavaScript library which provides the pronunciation of long numbers. It can read long numbers up to 303 digits (10^303).”
Let’s start by installing the library.
Installation: To install type the following line of code:
npm install spelljs
Example 1: We can use the spell library to spell a Number object like,
Javascript
import spell from 'spelljs' ;
console.log(Number(7782929).spell());
|
Output:
Example 2: We can also use the spell library to spell a String object like,
Javascript
import spell from 'spelljs' ;
console.log( '12237198273' .spell())
|
Output:
Reference: https://www.npmjs.com/package/spelljs
Share your thoughts in the comments
Please Login to comment...