-2

I have an array like this:

const arr = [1,2,3,4,5]

I want to achieve something like this:

let answer = 1,2,3,4,5

I want the typeof answer to be a number.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0
let answer = "1,2,3,4,5"

is possible but not what you asked.

const arr = [1,2,3,4,5];
let answer = arr.join(',');
console.log(answer);
farvilain
  • 2,552
  • 2
  • 13
  • 24