I'm working on a personal project right now ( I'm trying to plot a graph with the given expression in javascript), and I'm facing an issue.
Say s = "3x^2+4x+5", I'm trying to convert this into return 3*x*x + 4*x + 5, in the function
myGraph.drawEquation(function(x) {
return 3*x*x + 4*x + 5;
}, 'green', 3);
I've looked around and I came across eval(), but it needs to substitute a value into x. Other guides say that I need to make my own parser, but how do you create a parser that does the above?
Currently I have a function to convert s = "3x^2+4x+5" into ["+3x^2","+4x","+5"] into ["+3*x*x","+4*x","+5"], if that helps.
(Sorry for the multiple edits)