]> git.r.bdr.sh - rbdr/generador-de-insultos/blobdiff - lib/InsultGenerator.js
Add start command
[rbdr/generador-de-insultos] / lib / InsultGenerator.js
index e5ad2930906c796feb34b4e134a3e5568a8d15df..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"
       }