how to print array of 52/ print it 5 times with different value in javascript code example
Example 1: how to print array of 52/ print it 5 times with different value in javascript
function fillArray(value, len) {
var arr = [];
for (var i = 0; i < len; i++) {
arr.push(value);
}
return arr;
}
Example 2: how to print array of 52/ print it 5 times with different value in javascript
function fillArray(value, len) {
if (len == 0) return [];
var a = [value];
while (a.length * 2 <= len) a = a.concat(a);
if (a.length < len) a = a.concat(a.slice(0, len - a.length));
return a;
}
Example 3: how to print array of 52/ print it 5 times with different value in javascript
function fillArray(value, len) {
if (len == 0) return [];
var a = [value];
while (a.length * 2 <= len) a = a.concat(a);
if (a.length < len) a = a.concat(a.slice(0, len - a.length));
return dude
}