How to make code more efficiency?

I think there should have some other way (e.g create a function with passing arguments?) to make the following code more efficiency. But I can not figure out how to do that. Here are my code example:

   if (money >= weaponA_LV1Cost)
	{
		Instantiate (weaponA_LV1, buildPos, Quaternion.identity);					
		money = money - weaponA_LV1Cost;
	}
	
	if (money >= weaponB_LV1Cost)
	{
		Instantiate (weaponB_LV1, buildPos, Quaternion.identity);					
		money = money - weaponB_LV1Cost;
	}
	
	if (money >= weaponC_LV1Cost)
	{
		Instantiate (weaponC_LV1, buildPos, Quaternion.identity);					
		money = money - weaponC_LV1Cost;
	}

Something like this (Pseudocode):

    function checkBuy(cost, prefab)
    {
        if(money >= cost)
        {
            Instantiate (prefab, buildPos, Quaternion.identity);           
           money = money - cost;
        }
     }

     checkBuy(price1, weapon1);
     checkBuy(price2, weapon2);
     etc...

Thank you MadDave!
Sorry for the late reply. This should help my script looks more efficient!