I am trying to get a user Input and turn that into an array of string to my token. For some reason it is not working.
For example …Compute(5*6+7) should give token = ["5","**","6","+","7"]
function splitOperation(operation) {
return operation.match(/(\d+(\.\d+)?|[+\-*/])/g);
}
function Compute(userInput) {
let token = [splitOperation(userInput)];
}
let userInput = 5*6+7
Compute(userInput)
>Solution :
5*6+7 is a number.
To use "match" you need a string, use "5*6+7", if your regex is good, this should do it.