Keep getting "Unexpected" SyntaxErrors

Hello, I'm interested in making plugins, however, I'm working with events and script calls by now.
I'm coding a script that enables or disables a Switch if the two nearest spaces behind the player are passable or not, but when I check if it works, the game keeps throwing me "Unexpected" SyntaxErrors.

This is my first time doing something in Javascript. I have programmed in C# and Java, so I think I know what I'm doing with this script.
I will appreciate it if anyone points me the issue in these.

As a script call (where 3 is the Switch I want to manage):
Spoiler: This throws an "Unexpected token ;" Syntax Error
var AllowRegroup = false;
var Direction = $gamePlayer.direction();
var x = $gamePlayer.x;
var y = $gamePlayer.y;

switch (Direction)
{
default: break;
case 2: AllowRegroup = $game_player.passable?(x,y-1,2) && $game_player.passable?(x,y-2,2); break;
case 8: AllowRegroup = $game_player.passable?(x,y+1,8) && $game_player.passable?(x,y+2,8); break;
case 4: AllowRegroup = $game_player.passable?(x+1,y,4) && $game_player.passable?(x+2,y,4); break;
case 6: AllowRegroup = $game_player.passable?(x-1,y,6) && $game_player.passable?(x-2,y,6); break;
}
$gameSwitches.setValue(3, AllowRegroup);

As a script call inside a condition
Spoiler: This throws an "Unexpected end of input" Syntax Error
$gamePlayer.direction() == 2 && $game_player.passable?($gamePlayer.x,$gamePlayer.y-1,2) && $game_player.passable?($gamePlayer.x,$gamePlayer.y-2,2) ||
$gamePlayer.direction() == 8 && $game_player.passable?($gamePlayer.x,$gamePlayer.y+1,8) && $game_player.passable?($gamePlayer.x,$gamePlayer.y+2,8) ||
$gamePlayer.direction() == 4 && $game_player.passable?($gamePlayer.x+1,$gamePlayer.y,4) && $game_player.passable?($gamePlayer.x+2,$gamePlayer.y,4) ||
$gamePlayer.direction() == 6 && $game_player.passable?($gamePlayer.x-1,$gamePlayer.y,6) && $game_player.passable?($gamePlayer.x-2,$gamePlayer.y,6)

Thanks for your time and sorry for my english if something is wrong.
I doubt this is causing the problem, but variable names should begin with a lower case character.

$game_player.passable?(x, y, direction) is from VX Ace. It is $gamePlayer in MV, not $game_player. And I think it is .canPass(x, y, dir), not .passable? You've got it wrong on all of those lines.
I doubt this is causing the problem, but variable names should begin with a lower case character.

$game_player.passable?(x, y, direction) is from VX Ace. It is $gamePlayer in MV, not $game_player. And I think it is .canPass(x, y, dir), not .passable? You've got it wrong on all of those lines.

It worked! Thank you very much.
That makes a lot of sense. It seems I didn't noticed that on my research.
If you were wondering more about why it gave that error specifically - the "?" in JavaScript is reserved for the Conditional Operator which is a ternary operator. Ternary operators expect 3 arguments which is why it was confused by the ";" that ended the statement.

Original thread: https://forums.rpgmakerweb.com/threads/keep-getting-unexpected-syntaxerrors.89323/