Move a object on the x-axis with the mouse

I want to be able to move my object with my mouse on the x-Axis. Just like you move the beer box in this game: http://www.arandomgame.com/index.php?game_id=1078
I tried to search on google but they’re all in C-Sharp and i program in Javascript.

function Update () {
if (Get.MouseButton(1)){// if right mouse button is held down
var mousePos = Input.mousePosition;

      var wantedPos = Camera.main.ScreenToWorldPoint (Vector3 (mousePos.x, mousePos.y, 10)); 
 
      transform.position.x = wantedPos.x; 
   }
 }

Put this script on the item you want to be able to move. I use C# but I think this would work. This is untested script however, it should get you close. The link below is unity’s basic scripting things, and they help go between java C# and boo. So if there is a function you can only seem to find in one, see if you can find JS’s version through here

Mouse Input