/ Published in: JavaScript
This is part 1 of the requireJS tutorial
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
define([],function(){ var pool = ['a','b','c','d']; var Random = function(){ this.getRandomString = function(N){ var strToReturn = ""; for(var i = 0; i < N; i++){ var indexToPick = Math.floor((Math.random()*pool.length)); strToReturn += pool[indexToPick]; } return strToReturn; }; }; return Random; });