-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
  • 90,369
  • 161
  • 124
  • 175
  • You can get it like that...instead you can get it like this. .. "1,2,3,4,5" using string concatenation – AYK Nov 28 '20 at 10:11

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,418
  • 1
  • 12
  • 24