I have two if conditions to check a value, the two conditions are the same.
I must use if condition twice, and not if and else if.
Here the code below :
regexp = new RegExp("[458]", "gi");
valuesArray = [5, 8];
for(var i = 0; i < valuesArray.length; i++)
{
if(regexp.test(valuesArray[i]) == true)
{
console.log("true : "+valuesArray[i]);
}
if(regexp.test(valuesArray[i]) == false)
{
console.log("false : "+valuesArray[i]);
}
}
The javascript console output is :
true : 5
false : 5
true : 8
false : 8
But this should be (because 5 and 8 are in [458] regexp, so regexp test must return true) :
true : 5
true : 8
So why it doesn't work ? Have you an idea ?
Thank you, cordially.