'Find a shorter code for this function with If...else

What function do you suggest when you have a lot of parameters and only one condition to pass through? I want something like this.

function deleteClaimLine(secId, aBtn, cboF, lstServ, cboServ, cboServP, txtMont, txtAnn1, txtAnn2, txtAnn3, fileUpl, dBtn) {

            All variables...

            if (allParameters !== "") {
                allParameters.value = "";
            }
}

Actually, that's all conditions i have and i want to do it in only one line if possible:

            if (cboFamille !== "") {
                cboFamille.value = "";
            }
            if (lstServices !== "") {
                lstServices.value = "";
            }
            if (cboService !== "") {
                cboService.value = "";
                cboService.style.display = "none";
            }
            if (cboServiceP !== "") {
                cboServiceP.value = "";
            }
            if (txtMontant !== "") {
                txtMontant.value = "";
            }
            if (txtAnnee1 !== "") {
                txtAnnee1.value = "";
            }
            if (txtAnnee2 !== "") {
                txtAnnee2.value = "";
            }
            if (txtAnnee3 !== "") {
                txtAnnee3.value = "";
            }
            if (fileUpload !== "") {
                fileUpload.value = "";
            }


Solution 1:[1]

if i got your questions correctly, follow this example it might help you

function func(...allParameters) {
  if (!allParameters.includes(""))
     allParameters = allParameters.map(_ => "")
}

func('ts', 'js');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohamed Filahi