Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
//pickRandom.js
/* global adventurejs A */

/**
 * Return a random item from an array of strings.
 * @method adventurejs#pickRandom
 * @memberOf adventurejs
 * @param {String} string
 * @returns {String}
 */
adventurejs.pickRandom = function Adventurejs_pickRandom(arr) {
  if (!Array.isArray(arr)) return "";
  return arr[Math.floor(Math.random() * arr.length)];
};