How to check if player has an object in inventory

So…after the player picks up an object(flashlight i.e.), it goes to the inventory. How to check if the player has flashlight in inventory so he can use it. If the player doesn’t pick up flashlight, he can’t use it.

And after that, how to add small texture (indicator) of flashlight that shows that you have picked up the flashlight.

Flashlight script (js)
#pragma strict

var LightIntesity = 2.0;
var LightRange = 16.0;
var LightSpotAngle = 42.0;

var AudioFile1 : AudioClip;
var AudioFile2 : AudioClip;

bool CheckForItem (Item "Flaslight") {
    if (inventory.Contains("Flashlight")) {return true;}
    else {return false;}
}

function Start (){
	light.intensity = LightIntesity;
	light.range = LightRange;
	light.spotAngle = LightSpotAngle;
}

function Update (){
	if (Input.GetKeyDown(KeyCode.F)){		
		if (light.enabled == false){
		light.enabled = true;
		audio.clip = AudioFile1;
    	audio.Play();
		}
		else{
		light.enabled = false;
		audio.clip = AudioFile2;
    	audio.Play();
		}
	}
}

Pickup script (js)
#pragma strict

public var keyGrab : AudioClip;                         // Audioclip to play when the key is picked up.


private var player : GameObject;                        // Reference to the player.
private var playerInventory : PlayerInventory;      // Reference to the player's inventory.


function Awake ()
{
    // Setting up the references.
    player = GameObject.FindGameObjectWithTag("Player");
    playerInventory = player.GetComponent(PlayerInventory);
}


function OnTriggerEnter (other : Collider)
{
    // If the colliding gameobject is the player...
    if(other.gameObject == player)
    {
        // ... play the clip at the position of the key...
        AudioSource.PlayClipAtPoint(keyGrab, transform.position);
        
        // ... the player has a key ...
        playerInventory.hasKey = true;
        
        // ... and destroy this gameobject.
        Destroy(gameObject);
    }
}

PlayerInventory (js)
#pragma strict

public var hasKey : boolean;

Without seeing any code, I would assume the inventory is kept as a List. In that case I would use something like:

bool CheckForItem (Item wantedItem) {
    if (inventory.Contains(wantedItem)) {return true;}
    else {return false;}
}