I'm creating an inline code editor as a teaching tool. I'd like to be able to execute a string of code, then execute another string of code, and have both run in the same namespace, so the second eval can access variables defined in the first. Ideally, this'll run in a sandbox namespace, not global. But I could work with global if needed. Since this is a teaching tool, I want to be able to specify the variables in the string in the standard format. So the first eval string might be "var x=5;" and the second could be "console.log(x)", and should log 5.
Here is a jsfiddle code. If you could rewrite the function to get console to log "777" based on the existing data, that would be dandy.
VIzt6uNhBQ