]> git.r.bdr.sh - rbdr/generador-de-insultos/blobdiff - lib/InsultGenerator.js
remove test thing
[rbdr/generador-de-insultos] / lib / InsultGenerator.js
index 2d49dc1f4f44de592e77e08edf4a81f84e97cff4..5c40651a7493921e5dd5c118102d39b8d8ae4903 100644 (file)
@@ -149,9 +149,9 @@ var InsultGenerator = Class({}, "InsultGenerator")({
     },
 
     _getNoun : function _getNoun() {
-      var index;
+      var index, noun;
       index = Math.floor(Math.random()*this.nouns.length);
-      return Promise.resolve(this.nouns[index]);
+      return Promise.resolve(this.nouns[index].toLowerCase());
     },
 
     _generateInsult : function _generateInsult(verb, noun) {
@@ -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"
       }