MV Me, failing to write an if... else statement

Hello ladies, gentleman, and those in between/neither who are better at Javascript than I (SQL nerd here).

I have the following code that draws a nifty little preview menu (SRPG plugin for those curious):
Window_SrpgStatus.prototype.drawParameters = function(x, y) {
var lineHeight = this.lineHeight();
for (var i = 0; i < 6; i++) {
if (i==2 || i == 3)
continue;
var paramId = i + 2;
var x2 = x + 188 * (i % 2); //alright set if statement for the math here to change what i is for the placement
var y2 = y + lineHeight * Math.floor(i / 2); //alright set if statement for the math here to change what i is for the placement
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramId), x2, y2, 120);
this.resetTextColor();
this.drawText(this._battler.param(paramId), x2 + 120, y2, 48, 'right');
}
};
Spoiler: Picture for those who enjoy those
js error.png
Now my game doesn't use Magic Attack or Magic Defense so instead of 2 dummy parameters that do nothing, I'm hiding them. Now while I can hide params 2 and 3 the code still makes space for them because in the var x2 = and var y2 = lines they're doing math based on if variable 2 and 3 are there (leaving a blank line. I need it to basically say in the case where i > 1 ... treat it like it's i - 1

This attempt errors out:
var x2 = x + 188 * ((if (i>1) i-1 % 2
else
i % 2));

I... am at a loss as to why. I assume it's pesky syntax and I'm missing a , or ) somewhere. Thoughts?
Code:
for (var i = 0; i < 6; i++) {

Rather than getting too creative, why not break this into two for loops?

Code:
for (var i = 0; i < 2; i++) {
...
}

Code:
for (var i = 4; i < 6; i++) {
var paramId = i;
var x2 = x + 188 * (i % 2); //alright set if statement for the math here to change what i is for the placement
var y2 = y + lineHeight * Math.floor((i - 2) / 2);
...
}

P.S. Because you have this:
Code:
var paramId = i + 2
I have a feeling the parameter value you are display for attack, defense may not actually be the correct value.
The error is because if...else cannot be inlined. You can use the conditional operator instead, e.g.
JavaScript:
var x2 = x + 188 * (i > 1 ? (i - 1) % 2 : i % 2);
Alternatively, you can modify the value of your variable in a follow-up if...else, e.g.
JavaScript:
var x2 = 188;
if (i > 1)
  x2 *= (i - 1) % 2;
else
  x2 *= i % 2;
x2 += x;
(I've also added parentheses here because i - 1 % 2, without parentheses, equals i - 1.)
Code:
for (var i = 0; i < 6; i++) {

Rather than getting too creative, why not break this into two for loops?

Code:
for (var i = 0; i < 2; i++) {
...
}

Code:
for (var i = 4; i < 6; i++) {
var paramId = i;
var x2 = x + 188 * (i % 2); //alright set if statement for the math here to change what i is for the placement
var y2 = y + lineHeight * Math.floor((i - 2) / 2);
...
}

P.S. Because you have this:
Code:
var paramId = i + 2
I have a feeling the parameter value you are display for attack, defense may not actually be the correct value.
Worked! Couldn't have it take into consideration the two variables aren't there so I just manually moved 'move' and 'range' a bit higher and it honestly looks good enough!
Spoiler: Good Enough lol
js error good.png
The error is because if...else cannot be inlined. You can use the conditional operator instead, e.g.
JavaScript:
var x2 = x + 188 * (i > 1 ? (i - 1) % 2 : i % 2);
Alternatively, you can modify the value of your variable in a follow-up if...else, e.g.
JavaScript:
var x2 = 188;
if (i > 1)
  x2 *= (i - 1) % 2;
else
  x2 *= i % 2;
x2 += x;
(I've also added parentheses here because i - 1 % 2, without parentheses, equals i - 1.)
I will likely also give this a shot!
Just as a quick tip for future queries - you always want to use the CODE tags (the </> in the edit bar) when you post code.

Otherwise the forum's BBCode will swallow your indentations and bracketed characters.

Original thread: https://forums.rpgmakerweb.com/threads/me-failing-to-write-an-if-else-statement.160249/