So I’m having problems with how stuff appears on the display, specially after having used the clearCalc method. I don’t truly understand why.
It also bothers me that on line 48, if I call that console.log function with that argument the following “if” won’t work, while if I don’t run that line, it wil. does anyone know why?
JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g., /foo/g or /foo/y ). They store a lastIndex from the previous match. Using this internally, test() can be used to iterate over multiple matches in a string of text (with capture groups).
Try running this code on jsfiddle.net and see what happens: