Javascript game health bar using constructor.prototype

I am working on a group project for my code school and I have been tasked with writing the code for the health bar on our game to change colors as the players health decreases. I am only six weeks into this immersive course and I have read the documentation to no real grasp of the material.
Would someone kindly point me in the right direction on what this function would even look like??

So, do you wanna make a Health bar object and update values by means of prototypes? Using prototype, you can share generic methods across all object’s instances, such as one that makes a trivial number’s update.
For instance:

//===constructor===//
function HealthBar(color,length)
{
  this.barLength=length;
  this.color=color;
  this.isdead= false;
}

HealthBar.prototype.increase = function (amount) 
{
  if ( this.barLength<=100){this.barLength+=amount};
   this.changeColor();
}

HealthBar.prototype.decrease = function(amount)
{
 if (!this.isdead)
  {
         this.barLength-=amount;
  }
 this.changeColor;
}

HealthBar.prototype.changeColor= function()
{
   switch(this.barLength)
  {
     case (80<=this.barLength<=100):
     {
          this.color='yellow';
     }
      case (50<=this.barLength<=80):
     {
          this.color='orange';
     }
     ......
  }
}

const myHealthBar= new HealthBar('green',100);

I recommend to read these in the given order.


The readme from our instructor was to use constructor.prototype. Thank you for the McGinnis resources and helping me further understand what I wasn’t understanding. Your help has proven very helpful.