pluralizeME module helps you to singularize or pluralize a given word.
First of all, install pluralize-me
or
Then, you just need to import the singular and plural functions:
import{singular,plural}from'pluralize-me';
And use it!
constpluralWord=plural(`foot`);// Will return the string `feet`constsingularWord=singular(`feet`);// Will return the string `foot`
import{singular,plural}from'pluralize-me';constsingulars=['foot','computer'];letplurals=[];console.log('Testing singular --> plural');singulars.forEach(word=>{constpluralWord=plural(word);plurals.push(pluralWord)console.log(`The plural of${word} is${pluralWord}`);});console.log('---------------------------');console.log('Testing plural --> singular');plurals.forEach(word=>{console.log(`The singular of${word} is${singular(word)}`);});
The output of this simple code will be:
Testing singular --> pluralThe plural of foot is feetThe plural of computer is computers---------------------------Testing plural --> singularThe singular of feet is footThe singular of computers is computer