MZ Trying to code compare & counters for mini-game

Issue Summary — In my first game jam right now and trying to do a small little game with MZ, that mimics the old MasterMind tabletop game from ~1980. What I'm trying to do is via script in an event (instead of doing oodles of nested if statements in the event) is to, for two different sets of 4 variables, cycle through and record how many of each color code I've got. One set for the player colors & one for the hidden, goal colors. Then compare those two sets and see how many matches I've got for each color pair.

Details — I have 4 crystals that successfully cycle through 5 colors (each w/ their own variable with color codes 0-4) and switches that keep the crystals from moving whenever the room re-draws. There's also the hidden (to the player) goal series of 4 variables w/ their own randomly generated color sequence. The point of the game is to, through logic, get your color sequence to match the hidden one. This part all works, including tracking & reporting perfect matches. For testing, the goal colors are at the top.

I tried setting up the first part of the script (testing via interaction w/ the pig-butt instead of auto cycling w/ the room) but it's throwing a "SyntaxError, Unexpected token ')'" message. I hadn't written the second part, the comparing yet to test. I did check and there's no floating brackets or () so thinking it may be something not-obvious in the syntax.

Here's what I have so far, that's breaking:
var bookmark = 0;
for (var g = 5; g <=8; g++) {
bookmark = $gameVariables.value(g);
for (var i = 0; i<=4; i++) {
if (bookmark === i) {
$gameVariables.setValue(30+i,++);
$gameMessage.add($gameVariables(30+i));
}
}
}
The goal colors are stored in variables 5-8, player colors in 10-13.
I've got the counter variables for recording # of each color in 24-28 for the goal, and 30-34 for the player. Trying for each color for goal & player, to count how many of each color there are. So far the above is only testing the player bit, if I get it working I'd add a second identical bit for the goal series variables #'s 24-28.
Also have a counter to track #'s of colors matching (what I'll increment in the later compare bit).

Here's what I was going to try for the compare & count colors in both part, will this work right or am I messing up the syntax somewhere? Basically for each previously added up color tracker variable in the previous section, I want to increment the global color counter variable (#3) for each matching set. So example, if goal has 2 blues and player has 3 blues, it'll add 2 to the color counter. If goal has 2 yellows, player 1 yellow, then 1 gets added to the counter.

for (var c = 0; c <= 4; c++) {
if ($gameVariables.value(24+c) > 0 && $gameVariables.value(30+c) > 0) {
$gameVariables.setValue(3,++);
$gameVariables.setValue(24+c,--);
$gameVariables.setValue(30+c,--);
}
}


What tutorials or previous support threads have you referenced? — Tried hunting the forums but didn't quite find anything like this. I've been searching through the MV/MZ Script Calls google doc sheet (which is awesome)! which is where I found all the commands and syntax I thought I was using right. Though those two lines in the if(...) loop I'm guessing on how those commands might work in the .setValue(,) and .add()
Got the compare bit inspiration from this one, but that was switches and these are variables so hope I've altered them right. Check switches post

Are you using any plugins? — None, just base MZ

Attach any illustrative screenshots, full event pages with no cropping, mock ups, etc. — See attached, hope these are sufficient.

Thanks for all your help!
$gameVariables.setValue(3,++);
++ and -- by themselves arent values, so the game is still looking for one after it and crashes when it gets to the closing parenthesis.
if you want to increase and decrease a game variable by 1, then calling the value function within the setValue function and adding/subtracting 1 there is enough (you could use ++ and -- on the variable _data directly, but you need to be sure you're handling it properly). assuming all else is correct, change your setValue calls to do as mentioned
Code:
$gameVariables.setValue(3, $gameVariables.value(3)+1);

also...

I've moved this thread to Javascript/Plugin Support. Thank you.

Thank you, that makes sense. Will try that.
Yup, all works now, yay! Here's what I ended up having in the end (for reference).

var bookmark = 0;
for (var g = 10; g <=13; g++) {
bookmark = $gameVariables.value(g);
for (var i = 0; i<=4; i++) {
if (bookmark === i) {
$gameVariables.setValue(30+i,$gameVariables.value(30+i)+1);
}
}
}

And for the compare/counter:

for (var c = 0; c <= 4; c++) {
if ($gameVariables.value(24+c) > 0 && $gameVariables.value(30+c) > 0) {
$gameVariables.setValue(3,$gameVariables.value(3)+1);
$gameVariables.setValue(24+c,$gameVariables.value(24+c)-1);
$gameVariables.setValue(30+c,$gameVariables.value(30+c)-1);
}
}

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/trying-to-code-compare-counters-for-mini-game.179290/