I am embarking on a project to develop an uncomplicated graphing calculator that enables users to input a function of f (such as f(x) = x^2+2x+6). Essentially, the JavaScript code should replace the x in the function with a specific number and then compute the function using eval(). The difficulty arises when I want individuals to be able to type x^2 instead of utilizing the default JavaScript convention which would involve Math.pow(x,2). I assume this would involve deploying some form of regular expression, but my knowledge in this area is limited and I personally find it quite perplexing. Is there a way to convert a statement like x^3-x^2 to Math.pow(x,3)-Math.pow(x,2)?
Any assistance would be immensely appreciated.