Question: Write a function named getProduct(text) where text is a string showing the product of several positive integers. The function must evaluate the expression in text
Write a function named getProduct(text) where text is a string showing the product of several positive integers. The function must evaluate the expression in text and return the answer. For example, if text = "12*2*10" then getProduct(text) must return 240. Similarly, if text = "4*2*3*1" then getProduct(text) must return 24. You can assume that text is always a valid expression (e.g., as in the examples above) and will not contain any character other than digits and *
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
