programming-examples/js/Array/Write a JavaScript function to create a specified number of elements and pre-filled numeric value array..js
2019-11-15 12:59:38 +01:00

7 lines
194 B
JavaScript

function array_filled(n, val)
{
return Array.apply(null, Array(n)).map(Number.prototype.valueOf,val);
}
console.log(array_filled(6, 0));
console.log(array_filled(4, 11));