I’m playing around with code a bit to understand splicing better. Do you know why repl.it is throwing an error when I run this code:
function splicing(str) {
let arr = str.split('');
for(let i = 0; i < arr.length; i++) {
if(arr[i] === 'T') {
arr.splice(i,0,'S');
}
}
return arr;
}
splicing('ThisIsSpinalTap');
It’s sending this message:
RangeError: Potential infinite loop. You can disable this from settings.
at spinalCase:3:102
at eval:10:1
at eval
at new Promise