Question: in javascript I got it where the user can type a function and hit a button to evaluate it and print it out in a
in javascript I got it where the user can type a function and hit a button to evaluate it and print it out in a div --with eval(). My problem is I cant get console.log to work as the contents that contains the function is a string. I tried splice/split but how do I handle multiple console.logs?
Example function:
Textbox--
| function hi () { console.log("hi") console("goodbye") console.log("hello again") } |
button
input:
var content = "function hi () { console.log("hi)......}
var results = eval(content)
output:
render{
return(
)
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
