Thursday, 17 June 2021

Check value exist in array using Javascript

var preHSValues = userRole.HealthSystem.split(",");  

for (var i in hsOptions) {

                            var checkExistingValue = hsOptions.find(

                                opt => opt.value === preHSValues[i]

                            );

                            if (checkExistingValue) {

                                hsValuesNew.push(preHSValues[i]);

                            }

}

No comments:

Post a Comment