i am making a calculator as my first app and i want that user can enter a complete statement as string eg. "4+5-6*1".. can anyone tell me how to get a result from such a string?
3 Answers
Accepted Answer
Have you tried eval ?
eval("4+5-6*1") -> 3
Simply use the eval() javascript function. This will get you going.
Hi Hamza,
You can get result using string function like split function and after you get individual object do your calculation.
Your Answer
Think you can help? Login to answer this question!