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(

{results}

)

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!