If num is greater than 1 returns the plural form of the given string, else return the singular form.
Check if num is positive. Throw an appropriate Error if not, return the appropriate string otherwise. Omit the third argument, items, to use a default plural form same as item suffixed with a single 's'.
const pluralize = (num, item, items = item + 's') =>
+ num <= 0
+ ? (() => {
+ throw new Error(`'num' should be >= 1. Value povided was ${num}.`);
+ })()
+ : num === 1 ? item : items;
+
\ No newline at end of file
diff --git a/snippets/pluralize.md b/snippets/pluralize.md
index 0016a8c92..445ceca3b 100644
--- a/snippets/pluralize.md
+++ b/snippets/pluralize.md
@@ -5,15 +5,19 @@ If `num` is greater than `1` returns the plural form of the given string, else r
Check if `num` is positive. Throw an appropriate `Error` if not, return the appropriate string otherwise.
Omit the third argument, `items`, to use a default plural form same as `item` suffixed with a single `'s'`.
-``` js
-const pluralize = (num, item, items = item+'s') =>
- num <= 0 ? (() => {throw new Error(`'num' should be >= 1. Value povided was ${num}.`)})() : num === 1 ? item : items;
+```js
+const pluralize = (num, item, items = item + 's') =>
+ num <= 0
+ ? (() => {
+ throw new Error(`'num' should be >= 1. Value povided was ${num}.`);
+ })()
+ : num === 1 ? item : items;
```
```js
-pluralize(1,'apple','apples'); // 'apple'
-pluralize(3,'apple','apples'); // 'apples'
-pluralize(2,'apple'); // 'apples'
-pluralize(0,'apple','apples'); // Gives error
-pluralize(-3,'apple','apples'); // Gives error
+pluralize(1, 'apple', 'apples'); // 'apple'
+pluralize(3, 'apple', 'apples'); // 'apples'
+pluralize(2, 'apple'); // 'apples'
+pluralize(0, 'apple', 'apples'); // Gives error
+pluralize(-3, 'apple', 'apples'); // Gives error
```
diff --git a/tag_database b/tag_database
index e8c53adce..ea05bbcb5 100644
--- a/tag_database
+++ b/tag_database
@@ -111,6 +111,7 @@ palindrome:string
percentile:math
pick:array
pipeFunctions:adapter
+pluralize:uncategorized
powerset:math
prettyBytes:utility
primes:math