Looking at your code more closely... where did you learn JavaScript? Because creating an inline anonymous function, and then invoking it with eval with each iteration of the loop highlights a few critical misunderstandings.
First of all, eval is dangerous since it simply evaluates the string it's passed. Chances are, the string you built is cannot be evaluated the way you want. Ultimately, there's no reason to use it here.
Second, the entire point of functions is to have a piece of code that can be used repeatedly. Building an anonymous function in a loop, only to build it again over and over again negates the entire point, and is also costly in terms of execution time. There's no reason why you couldn't write a named function called "Swap" that took two cells as arguments and swapped their values.
It really seems like the programming competitions you were a part of did more harm than good. Speed isn't the end-all, be-all of programming. https://developer.mozilla.org/en-US/docs/Web/JavaScript
First of all, eval is dangerous since it simply evaluates the string it's passed. Chances are, the string you built is cannot be evaluated the way you want. Ultimately, there's no reason to use it here.
Second, the entire point of functions is to have a piece of code that can be used repeatedly. Building an anonymous function in a loop, only to build it again over and over again negates the entire point, and is also costly in terms of execution time. There's no reason why you couldn't write a named function called "Swap" that took two cells as arguments and swapped their values.
It really seems like the programming competitions you were a part of did more harm than good. Speed isn't the end-all, be-all of programming. https://developer.mozilla.org/en-US/docs/Web/JavaScript