3 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL licenses
4 * http://phpjs.org/functions/range
5 * original by: Waldo Malqui Silva
8 function range( low, high, step ) {
9 // Create an array containing the range of integers or characters
10 // from low to high (inclusive)
13 // discuss at: http://phpjs.org/functions/range
14 // + original by: Waldo Malqui Silva
15 // * example 1: range ( 0, 12 );
16 // * returns 1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
17 // * example 2: range( 0, 100, 10 );
18 // * returns 2: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
19 // * example 3: range( 'a', 'i' );
20 // * returns 3: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
21 // * example 4: range( 'c', 'a' );
22 // * returns 4: ['c', 'b', 'a']
30 if (!isNaN(low) && !isNaN(high)) {
33 } else if (isNaN(low) && isNaN(high)) {
35 inival = low.charCodeAt(0);
36 endval = high.charCodeAt(0);
38 inival = (isNaN(low) ? 0 : low);
39 endval = (isNaN(high) ? 0 : high);
42 plus = ((inival > endval) ? false : true);
44 while (inival <= endval) {
45 matrix.push(((chars) ? String.fromCharCode(inival) : inival));
49 while (inival >= endval) {
50 matrix.push(((chars) ? String.fromCharCode(inival) : inival));