+1 vote
by
function maskify(cc) {
let arr = cc.split('');
arr.splice(-1,4);
return arr
}
by
I need to remove the last 4 elements.

3 Answers

0 votes
by
The string also has a slice:

function maskify(cc) {
return cc.slice(0, -4);
}
If you need an array on the output:
function maskify(cc) {
return cc.slice(0, -4).split('');
}
0 votes
by
What's with all the array and splice stuff? There is a substr:
https://developer.mozilla.org/ru/docs/Web/JavaScri...
0 votes
by
let a = [1,2,3,4,5,6]
a.reverse().slice(4).reverse()
...