need help converting gun script from c# to javascript

a user named BMayne answered my question here

he gave this script as a answer to show me a better way to do that kind of shooting

float currentAmmo = 5.0f;
float currentReloadTime = 0.0f;
bool isReloading = false;
const float RELOAD_TIME = 2.0f;
const int MAX_AMMO = 8; 
void Update()
    if (Input.GetKeyDown(KeyCode.R))
        if (currentAmmo != MAX_AMMO && !isReloading) // if we already have max ammo lets leave or if we are already reloading
            isReloading = true; // We are now reloading
            currentReloadTime = RELOAD_TIME; //Set our current load time 
    if (isReloading)
void GunStep()
    if (currentAmmo <= 0)
        return; //No ammo so we leave.
    if (!Input.GetMouseButtonDown(0)) //the '!' means Not. so the mouse button is Not Down 
        return; //We are not firing so we don't need to be here
    //We fired our gun so we need to use a bullet 
    //Start our making our raycast
    RaycastHit hit;
    Ray ray = Camera.main.ScreenPointToRay(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0.0f));
    //Fire the ray and tell anything we hit to apply damage
    if (Physics.Raycast(ray, out hit, 100))
        hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
void ReloadStep()
    currentReloadTime -= Time.deltaTime; //We count down
    if( currentReloadTime <= 0.0f )
        isReloading = false;
        currentAmmo = MAX_AMMO;

and I use javascript so i was wondering if someone could convert this to javascript
so i can understand it better. thanks in advance.

This might help: Convert c# to Js? - Unity Answers

If you read through the answer and comments, you’ll find a bunch of references for how to do this yourself.