I've been troubleshooting this code line by line in the console, and everything seems to be working fine. However, when I input consecutive even numbers, my browser freezes. The solution is probably right in front of me, but I just can't figure it out at the moment. Here's the code snippet:
$('body').append('<input type="number" id="myInput"><input type="submit" id="submit">');
$('#submit').click(function(){
var myVal = $('#myInput').val();
myArray = myVal.split("");
for (var i = 0; i < myArray.length -1; i++){
if((myArray[i]%2 == 0) && (myArray[i+1]%2 == 0)){
myArray.splice(i,0,'-')
}
}
console.log(myArray);
});