Little Help for my Demo Math Game

I have problems with my simple math game. The answer for the operation is wrong; I think it did not go into one of the conditioning on my script. I think showing pictures is a better explanation.
I'm a beginner with things like this, but I think I have no big problem with the variables.
1.png

The problem is with this, having an issue with the conditioning.
2.png

Proof of the problem, the answer is just for testing.
3.png
That's some pretty bizarre code...
If I want to cut it short :

event.PNG


Works pretty well this way. You don't even need to initiate the random value beforehand. I still can't figure why yours doesn't work. It looks fine tho.

Edit : Here's a copy :

Code:
var tary = [' + ', ' - ', ' * ', ' / '];
tary = tary[Math.randomInt(tary.length)];
var a = 1 + Math.randomInt(50);
var b = 1 + Math.randomInt(50);
$gameVariables.setValue(1, a.toString() + tary + b.toString());
$gameVariables.setValue(2, eval($gameVariables.value(1)));
@HayaEdu Kuro's solution looks sound; just as an explanation, I believe your plus variable is getting assigned incorrectly:
Code:
plus=$gameVariables.setValue(13,ope);
The setValue "function" is actually a method (JavaScript doesn't formally distinguish the two) without an explicit return value, meaning the plus variable remains undefined.

For future reference, you may find console.log() useful. To see how it works, make a simple map event with the following script call:
Code:
var test = $gameVariables.setValue(1, 2);
console.log('Value of test is now', test);
Press F8 during test-play to open the console window, then activate the event to see the message! Very useful when debugging. ^_^
Wow, thanks for helping guys! I learned something new today, will reply again if I finally solved it.

I finally did it, and I'm going to post another problem I have.

Original thread: https://forums.rpgmakerweb.com/threads/little-help-for-my-demo-math-game.97791/