help with Flashlight Pickup

First and formost- I need the coding to be in JAVASCRIPT not C SHARP

Hey Guys, I’ve read a couple other questions related to this, but they both involved batteries. I don’t want batteries for the flashlight in my game. I just want for the player to be able to walk over to a table, and click E to pickup the flashlight. BUT I do want them to be able to turn it on and of with the F key.
I already have the script for the flashlight turning on and off writen, I just dont now how to incorporate the whole PICKUP part off it where they wont me able to turn it on until they pick it up. This is what I have so far.

private var lightSource : Light;
var soundTurnOn : AudioClip;
var soundTurnOff : AudioClip;

function Start () {
lightSource = GetComponent(Light);

}

function Update () {

if (Input.GetKeyDown(KeyCode.F)) ToggleFlashLight();

}

function ToggleFlashLight () {

lightSource.enabled=!lightSource.enabled;

//Audio
if (lightSource.enabled) {

audio.clip = soundTurnOn;

} else {

audio.clip = soundTurnOff;

}

audio.Play();

}

@script RequireComponent(AudioSource)
@script RequireComponent(Light)

For picking up the flashlight, I would do something like this:

var worldModel : GameObject;
var viewModel : GameObject;
var actualLight : Light;
var hasLight : boolean = false;

function OnTriggerEnter (other : Collider) {
    if(other.name == "player name here") {
        hasLight = true;
        Destroy(worldModel);
        Destroy(this);
    }
}

function Update () {
    if(hasLight == true) {
        viewModel.active = true;
        actualLight.enabled = true;
    }
    else {
        viewModel.active = false;
        actualLight.enabled = false;
    }
}

As for turning it on and off, I would make another script.

var actualLight : Light;
var on : boolean = true;
var soundTurnOn : AudioClip;
var soundTurnOff : AudioClip;

function Update () {
    if(Input.GetKeyDown("f")) {
        on = !on;
        if(on == true) {
            audio.PlayOneShot(soundTurnOff);
        }
        else {
            audio.PlayOneShot(soundTurnOn);
        }
        
    }
    if(on == true) {
        actualLight.enabled = true;
    }
    else if(on == false) {
        actualLight.enabled = false;
    }
}