Creating duplicate array

Report a typo

Complete the missing parts in the function createDuplicateArray that takes two parameters: an element and a number n.

The function should return an array of length n, where every element is the given element.

Fill in the gaps with the relevant elements
function createDuplicateArray(element, n) {
    return Array().();
}
console.log(createDuplicateArray("x", 5)); // Output: ["x", "x", "x", "x", "x"]

Create a free account to access the full topic