Pluralizer

Size
2,576 Kb
Views
4,048

How do I make an pluralizer?

What is a pluralizer? How do you make a pluralizer? This script and codes were developed by Anthony Keithley on 24 December 2022, Saturday.

Pluralizer Previews

Pluralizer - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pluralizer</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="container">
<img src="https://s16.postimg.org/75cwpze91/plural.jpg">
<h2>Please enter a word:</h2>
<input id="input" type="text" label="word" id="word" onkeydown="enterKey()"></input>
<button class="button1" id="btn" onclick="plur()">PLURALIZE!</button>
<p>Plural: <span id="result"></span></p>
</div> <script src="js/index.js"></script>
</body>
</html>

Pluralizer - Script Codes CSS Codes

h1 { color: blue;
}
.button1 { background: blue; color: white; box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.button1:hover { box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
#container { width: 600px; margin: 0 auto; text-align: center;
}
#input {
}
img { border: 50px solid rgba(255, 0, 0, .3);; z-index:999;
}

Pluralizer - Script Codes JS Codes

function enterKey(){ if(event.keyCode == 13){ document.getElementById("btn").click(); }
}
function plur(){ var word = document.getElementById("input").value.toLowerCase(); //last letter var last = word.charAt(word.length - 1); //second to last letter var secToLast = word.charAt(word.length - 2); //last two letters var lastTwo = word.substring(word.length - 2); //all but the last letter of the word ex: Brush --> brus var allButLast = word.substring(0, word.length - 1); //Output var result = word + "s"; //Words that get 'es' when plural if(word.substring(word.length - 2) == "ch" || word.substring(word.length - 2) == "sh" || last == "s" || last == "x" || last == "z"){ if(word == "ox"){ result = "oxen"; } else { result = word + "es"; } } //End in single z if(last == "z"){ if(secToLast != "z"){ result = word + "zes"; } } //Words that end in o if(last == "o"){ if(isVowel(secToLast)){ result = word + "s"; } else { result = word + "es"; } } //Words that end in f if(last == "f"){ if (secToLast != "l"){ result = word + "s"; } else { result = allButLast + "ves"; } } //Words that end in fe if(word.substring(word.length - 2) == "fe"){ result = word.substring(0, word.length - 2) + "ves"; } //Words that end in y if(last == "y" && !isVowel(secToLast)){ result = allButLast + "ies"; } //Special words if(word == "index"){ result = "indices"; } if (word == "moose"){ result = "moosen"; } if(word == "child"){ result = "children"; } if(word == "person"){ result = "people"; } if(word == "man"){ result = "men"; } if(word == "woman"){ result = "women"; } if(word == "goose"){	result = "geese"; } if(word == "deer" || word == "buffalo" || word == "aircraft" || word == "fish" || word == "offspring" || word == "sheep" || word == "species" || word == "trout" || word == "salmon"){	result = word; } if(word == "mouse"){	result = "mice"; }
document.getElementById("result").innerHTML = result;
}
//returns true if char is a vowel, false if it is a consonant
function isVowel(char){ if (char == "a" || char == "e" || char == "i" || char == "o" || char == "u"){ return true; } else { return false; }
}
Pluralizer - Script Codes
Pluralizer - Script Codes
Home Page Home
Developer Anthony Keithley
Username KeithleySLHS
Uploaded December 24, 2022
Rating 3
Size 2,576 Kb
Views 4,048
Do you need developer help for Pluralizer?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Anthony Keithley (KeithleySLHS) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!