Create Array

Description


Given an integer size, return array of length size filled with 1s.

Example

For size = 4, the output should be createArray(size) = [1, 1, 1, 1].

Input/Output

  • [execution time limit] 4 seconds (js)

  • [input] integer size

    A positive integer.

    Guaranteed constraints:
    1 \leq size \leq 1000.

  • [output] array.integer

[JavaScript (ES6)] Syntax Tips

1
2
3
4
5
6
// Prints help message to the console
// Returns a string
function helloWorld(name) {
console.log("This prints to the console when you Run Tests");
return "Hello, " + name;
}

Solution


1
2
3
function createArray(size) {
  return Array(size).fill;
}