Hope someone can help as I quite new to JS. I need to extract a number from 2 strings then test the result for equality against each other.
For example
var test1 = "7D"
var test2 = "7H"
To extract the numbers I'm using the following code,
test1.match(/\d+/) = result in the console is "7",
I do the same for the test2 variable and this results in 7 also.
However when I test for equality using
test1.match(/\d+/) === test2.match(/\d+/) it evaluates to false.
I'm trying to use this condition in an if statement but cannot get it to work, e.g.
if(test1.match(/\d+/) === test2.match(/\d+/)){run some code}
Am I doing something wrong or is there a better way to acheive this?
Thanks,