My code looks like this:
function testfunc() {
var exp = /aa/gi;
var ret = [];
var test = ['aaa', 'aaa', 'aaa', 'aaa', 'aaa', 'aaa'];
for (var j = 0; j < test.length; j++) {
ret.push(exp.test(test[j]));
}
console.log(ret);
}
testfunc();
Instead of returning
[true, true, true, true, true, true]
it returns
[true, false, true, false, true, false]
I don't understand why!
Is there anything wrong in my code?