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

/* global AdventureJS A */

/**
 * Set the case of a string.
 * @method AdventureJS.Game#setCase
 * @memberOf AdventureJS
 * @param {String} text
 * @param {String} text_case
 * @returns {String}
 */
AdventureJS.FX.setCase = function AdventureJS_setCase(text, text_case) {
  switch (text_case) {
    case "lower":
      return text.toLowerCase();

    case "upper":
      return text.toUpperCase();

    case "title":
    case "mixed":
      return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();

    default:
      return text;
  }
};