Strange behavior of .match() function..

hey I'm here again asking for infos:

this is the first common event script call that works well:

function makeid(length) {
var result = '';
var characters = 'LETTERS';
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
word = makeid(Math.randomInt(2)+50);
$gameVariables.setValue(29, word);

then i call a conditional branch: ($gameVariables.value(29).match(/text/g) || []).length > 0



THEN, in another common event:

$gameVariables.value(28).push($gameActors.actor(18).name().toUpperCase())

conditional call: ($gameVariables.value(28).match(/text/g) || []).length > 0


how can the first common call event works and the second no?
in the first call event page maybe the big script interact in some way that I don't understand?

I'm really confused..

this is the error message:" $gameVariables.value(...).match is not a function"
$gameVariables.value(28) results to be an array, because of .push(val)

by retrieving value(28), you're returning an array, not a string.

print index 28 and double check it.... if it's a string, double check the regex... if not, there's your answer.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/strange-behavior-of-match-function.121284/