Pre-release
AdventureJS Docs Downloads Devlog
Score: 0 Moves: 0
// getThirdPersonSingular.js

(function () {
  /* global AdventureJS A */

  var p = AdventureJS.Dictionary.prototype;

  /**
   * Get the third person singular form of the provided verb.
   * @memberOf AdventureJS.Dictionary
   * @method AdventureJS.Dictionary#getThirdPersonSingular
   * @param {String} verb_name
   */
  p.getThirdPersonSingular = function Dictionary_getThirdPersonSingular(
    verb_name
  ) {
    if (
      verb_name.endsWith("ch") ||
      verb_name.endsWith("sh") ||
      verb_name.endsWith("x") ||
      verb_name.endsWith("s") ||
      verb_name.endsWith("z") ||
      verb_name.endsWith("o")
    ) {
      return verb_name + "es";
    } else if (verb_name.endsWith("y") && !/[aeiou]y$/.test(verb_name)) {
      return verb_name.slice(0, -1) + "ies"; // Change "y" to "ies"
    } else {
      return verb_name + "s"; // Default case
    }
  };
})();