Taking into account that the input is an array, you could save some bytes by replacing [...a] with just a (for golf purposes).
Apart from that, the solution seems really specific to the problem, and doesn't work for different arrays. For example:
f(['ace', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'])
//["ace", "four", "two", "five", "three", "six", "four", "seven"]
// there are 2 "four" and no "eight"
Thanks a lot for the input! The problem was in the 2.5 usage, which had to be replaced with a.length/2-.5. I updated my answer!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.