var arrayOfLight = function (x) { // note that x must be a positive number // prints from 0 to that number var result = []; for (var i = 0; i <= x; i++) { result.push(i); } return result; }; var response = arrayOfLight(5); // = [0, 1, 2, 3, 4, 5] console.log(response);