I am trying to join the 2nd and 3rd elements into one on the array i.e: [567, "O/S", '1,111']
Possible strings: 567/O/S/1,111 / 5/O/S/1,111 (The first element in the array could be up to 4 digits long)
I've got this working below but its not a very eloquent solution, is there a better way to do this? Possibly an es6 array function?
var array = '567/O/S/1,111'.split('/') if(array.length > 3) { var text1 = array[1]; var text2 = array[2]; var joinedText = `${text1}/${text2}`; array.splice(1,2); array.splice(1, 0, joinedText); } console.log(array) //[567, "O/S", '1,111']