Given an array
[9,5,4,2,1,1,5,8,1,1]
is there a way to remove all the 1s and add equal amount of xs at the end.
To get this
[9,5,4,2,5,8,x,x,x,x]
Am looking for a way to do this in one line. Curious if there is a technique here I may be missing or maybe there is none.
I am clearly wrong in my use of this in the below example. But gives you an idea of what I am trying to do.
let test = [9,5,4,2,1,1,5,8,1,1];
console.log(test.map(el => el !== 1 ?el :this.push('x'));