forked from SoftwareAG/appsim-wm-io-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
28 lines (25 loc) · 799 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function removeSpacesAndLowerCase(str) {
// Remove white spaces using regular expression
const stringWithoutSpaces = str.replace(/\s/g, '');
// Convert the string to lowercase
const lowerCaseString = stringWithoutSpaces.toLowerCase();
return lowerCaseString;
}
function pluralizeNoun(str) {
// function to return plural string of noun
if (str.endsWith("ss")) {
return str + "es";
} else if (str.endsWith("y")) {
return str.slice(0, -1) + "ies";
} else if (str.endsWith("us")) {
return str.slice(0, -1) + "es";
} else if (str.endsWith("s")) {
return str.slice(0, -1);
} else {
return str + "s";
}
}
module.exports = {
removeSpacesAndLowerCase: removeSpacesAndLowerCase,
pluralizeNoun: pluralizeNoun
};