How to translate this from c# to javascript?

I am looking at sample code written in C# (whole code can be found here: 2D_Racegame_Zelfstudie: Syncing powerups) and I wonder how to write this with js;
The part I am banging my head up the wall is this public something like function;

public int ApplyPowerUp(PlayerProperties playerStatus)
{
  switch(powerUpType)
  {
    case PowerType.Projectile :
      if(playerStatus.playerState == PlayerProperties.PlayerState.CarNormal)
      {
        Debug.Log("We have a projectile!");
        playerStatus.playerState = PlayerProperties.PlayerState.CarProjectile;
        playerStatus.hasProjectile = true;
        playerStatus.changeState = true;
      }
    break;
			
    return (int)powerUpType;
  }
}

Thank you in advance for your answer! :slight_smile:

debug.log in javascript is console.log(‘we have a projectile coming’)
so here is your code in java

i can’t help you with the public int thing though

switch(powerUpType) {
     case PowerType.projectile ;
       if (playerStatus.playerState == PlayerProperties.PlayerState.carNormal) {
console.log(' We have a projectile!');

playerStatus.playerState = PlayerProperties.PlayerState.CarProjectile;
playerStatus.hasProjectile = true;
playerStatus.changeState = true;
}
break;

default {
//you need a default just set it to anything you want
}

console.log( (int) + powerUpType);
}
// return is only valid in a function