Reputation: 1124
let's say I have got an array of [2, 4, 5, 6]
.
I want to be able to convert it to 2456
.
Is there an easy and elegant way to do this in JavaScript?
I am aware of this question.
Upvotes: 1
Views: 735
Reputation: 28414
Using Array#join
:
const arr = [2, 4, 5, 6];
const str = arr.join('');
console.log('string', str);
console.log('number', +str);
Upvotes: 1