How to use unlimited parameters in a function? (JS)

Hi! For my game i’m making a space colony game, were you can build buldings, so i’m making a function that builds the buildings. But I would like to make it so it can have an unlimited amount of integer values put in. These would be the resources required to build the building, and i would check with a for loop if you have enough and if you do you can build the building. But how to I do this? I know in java you would use … but how do you do this in javascript?

This seems vague to me, this would be pretty similar to regular Java or javascript concept wise.

Well, this might give you some ideas.

function Start ()
	//call function & check if it returns true
    if (checkResources(3, 5, 2, 8) == true)

//setup function...
function checkResources(wood, woodAmountNeeded, metal, metalAmountNeeded) {

    if(wood == woodAmountNeeded && metal == metalAmountNeeded)
        Debug.Log("You have enough wood & Metal");
        return true;
        Debug.Log("not enough supplies");
	    return false;



I’m not sure why you need a for loop for this, nor why you would need unlimited integers or what that even means…Can’t you just add parameters and arguments as you need them? Also sorry, I normally write in C# so, my unityscript is rather on the sorry side.