'If' Statement in javascript giving me problems

I’m trying to write a ‘IF’ statement for my health system heres the code I have.

var healthmin = 0;
var health = 100; 
var GUIhealth : GUIText;
var text = "Health: ";



function Update(){
 if (healthmin == 1)
 {
  health--; 
  GUIhealth.text = text + health.ToString();
 }
 else
 {
  GUIhealth.text = text + health.ToString();
 } 


function OnTriggerEnter( other : Collider ) { 
 if (other.tag == "zom") 
 {
  var healthmin = 1;
 } 
}

function OnTriggerExit( other : Collider ) {
 if (other.tag == "zom")
 {
  var healthmin = 0;
 }
}

but its giving me that this error “Assets/playerhealth.js(21,10): BCE0044: expecting (, found ‘OnTriggerEnter’.” but I know there is nothing wrong with the ‘OnTriggerEnter’ Function because If i take the ‘If’ statement for the ‘healthmin’ on Function Update it works fine, There is something wrong with the Function Updates ‘IF’ Statement that I can’t figure out, what am I doing wrong here?

There’s a } missing after

else { GUIhealth.text = text + health.ToString(); }

You’re closing the else statement, but not the function. That’s why the compiler is thrown off the path and isn’t expecting OnTriggerEnter.

Please use proper code indentation. This helps you seeing these things a lot easier.

I think you are missing a parenthesis after the end of your Update() function. You cannot have an on trigger enter function inside your update function also.

var healthmin = 0; 
var health = 100; 
var GUIhealth : GUIText; 
var text = "Health: ";

function Update(){ 
   if (healthmin == 1) { 
      health--; 
    GUIhealth.text = text + health.ToString(); 
}
 else { 
     GUIhealth.text = text + health.ToString(); 
  }
}

function OnTriggerEnter( other : Collider ) {
 if (other.tag == "zom") { 
var healthmin = 1;

      }
 }

function OnTriggerExit( other : Collider ) {

 if (other.tag == "zom") {
 var healthmin = 0; 
     }
 }

var thisHurts : bool = false;
var health:float = 100.0;
var GUIhealth : GUIText;
var text = "Health: ";

function Update(){ 
    if (thisHurts) { 
        health -= Time.deltaTime; // Subtracting in this way will make the damage-rate frame rate independent 
    }

    GUIhealth.text = text + health.ToString(); // you were doing this no matter what..
}

function OnTriggerEnter( other : Collider ) {
    thisHurts = (other.tag == "zom");
}

function OnTriggerExit( other : Collider ) {
    thisHurts = !(other.tag == "zom");
}