I’m trying to make a small function to get comfortable with (and to stop confusing splice, and slice.). According to w3Schools .splice() takes 3 arguments, (index at which to begin adding/removing elements, # of elements to be removed, and what to add.). Why does this function not work? P.S. Ignore they y, its just there as part of my experimenting.
let x = "Hello I like milk";
let y = '';
if(x[0] !== '(') {
x = x.split(' ').splice(0, 0, '(');
}
console.log(x)