Receive error on code without errors, retype or recopy, rerun and receive product

I have had this problem many times. On repl, a coding tool that shows the console, I put down some code. I had been using that code for a while and had not restarted the computer since beginning the problem. I have had a few errors but now the code is clean. There is an error message. I check the code and there is no error. If I run a function again, the error message persists. In this situation, I retype the code snippet without errors, then it runs. How does this problem work so that it may be prevented as code snippets get longer?
This is a code snippet that ran the error until I retyped it. I suppose I could copy and paste to retype quickly if this problem is going to be recurrent.

//Difference of two arrays
function diffArray(first, second)  {
  let result = [];
  for (let i = 0; i < first.length; i++)  {
    if (second.indexOf(first[i]) === -1 ) {
  for (let i = 0; i < second.length; i++) {
    if (first.indexOf(second[i]) === -1)  {
  return result;
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
//Result of 4.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.56.

Challenge: Diff Two Arrays

Link to the challenge:

I believe you can refresh the webpage to get to restart.

I can keep trying small fixes to reload including using refresh that your mentioned.