What I want is something like Array.join(separator), but which takes a second argument Array.join(separator, beforeLastElement), so when I say [f
Array.join(separator)
Array.join(separator, beforeLastElement)
[f
For me the simplest solution is:
['1', '2', '3'].reduce((previous, current, index, array) => { if (index === array.length - 1) { return previous + ' & ' + current; } else { return previous + ', ' + current; } })