Unexpected EOF at Function; How can I run multi-line code with Function class

I am making a piece of code that pulls js from input and runs it with new Function() class. If I need to run multi-line code from the input box then how do I stop the error?

ERROR:{EOF: Unexpected EOF at Function(...)}

When I log the input to the console it is

let a = "hi" nconsole.log(a) nwindow.alert(a)