Charge Jump script (Javascript)

Does anyone know how to make a Charge jump script in Javascript. I am pretty new at Javascript so I didn’t know how to.

So when you hold the “W” key down depending on how long you hold it thats how high you would go.

I already have jump and move script but I also need to know where you would put the charged the jump script or if you would make a whole new script

-------------------------------------------------------------------------------------

#pragma strict 

var rotationSpeed = 400;

var jumpHeight = 10;

var jumpHeight2 = 10;

var isFalling = false;




function Update ()

{

// this is to Handle the Ball rotation.

var rotation : float = Input.GetAxis("Horizontal") * rotationSpeed;
 

rotation *= Time.deltaTime;

GetComponent(Rigidbody).AddRelativeTorque(Vector3.back * rotation); 
 

// this is to help the ball jump.

if (Input.GetKey(KeyCode.W)&& isFalling == false)

{ 

GetComponent(Rigidbody).velocity.y = jumpHeight; 
    
 
}
 
}
 

function OnCollisionStay ()

{ 

isFalling = false;

}
 

function OnCollisionExit ()

{ 

isFalling = true;

}



-------------------------------------------------------------------------------------

I currently don’t have any errors.

you can put something like this:

var speed = 0;
var chargeJump = 0;
var chargeRate = 0.5;
var charging = 0;
 
function Update(){
	var rotation : float = Input.GetAxis("Horizontal") * rotationSpeed;
	rotation *= Time.deltaTime;
	GetComponent(Rigidbody).AddRelativeTorque(Vector3.back * rotation); 

	if (Input.GetKey(KeyCode.W)&& isFalling == false){
		charging = 1;
		chargeJump = 0;
		speed = 0;
	}

	if (charging==1){
		chargeJump += chargeRate * Time.deltaTime;
		speed = chargeJump;
		print("The variable is :"+speed);
	}
 
	if (Input.GetKeyUp(KeyCode.W)&& isFalling == false){
		GetComponent(Rigidbody).velocity.y = jumpHeight;
		isFalling = true;
		chargeJump = 0;
		charging =0;
		speed = 0;
	 }
 }

 function OnCollisionStay (){
	isFalling = false;
 }

 function OnCollisionExit (){ 
	isFalling = true;
 }

If you want, you can put a limit of how much you want to make to jump.