I am trying to create a function that takes in two vairables a
and b
, this function will create an array with variable a
reapeated b
times.
This is how far I have gone but It's not outputting th correct number of items in the array:
var createArr = function(a, b) {
// returns an array with variable a repeated b times.
if (typeof b == 'number') {
var arr = [];
for (var i = 0; i <= b; i++) {
arr.push(a);
};
}
return arr;
};
createArr("ready",3)