From: Ben Beltran Date: Sun, 6 Sep 2015 01:24:11 +0000 (-0500) Subject: Don't pluralize words that end with s X-Git-Url: https://git.r.bdr.sh/rbdr/generador-de-insultos/commitdiff_plain/24e8fabaa7290a2deb99f890b1f4cc84b784fc59?ds=sidebyside;hp=--cc Don't pluralize words that end with s --- 24e8fabaa7290a2deb99f890b1f4cc84b784fc59 diff --git a/lib/InsultGenerator.js b/lib/InsultGenerator.js index 7951204..5c40651 100644 --- a/lib/InsultGenerator.js +++ b/lib/InsultGenerator.js @@ -160,8 +160,15 @@ var InsultGenerator = Class({}, "InsultGenerator")({ // Super dumb pluralizer _pluralize : function _pluralize(noun) { - console.log(noun); - if (["a","e","i","o","u"].indexOf(noun[noun.length - 1]) >= 0) { + var lastLetter; + + lastLetter = noun[noun.length - 1]; + + if (lastLetter === "s") { + return noun; + } + + if (["a","e","i","o","u"].indexOf(lastLetter) >= 0) { return noun + "s" }