javascript – How to convert numbers to array?

Question:

The bottom line is that I can not get the full array of numbers. That just did not sort through for this, but it only puts the first value into the array.

How to solve this problem? I tried to convert it to a string, but it also only outputs 1 value.

function mostNumbers(numbers) {
  var arr = [numbers];
  console.log(arr);
}

console.log(mostNumbers(1, 2, 3));

Answer:

Or like this:

function mostNumbers() {
  return Array.from(arguments);
}
console.log(mostNumbers(3, 2, 7));

Array.from

Scroll to Top