I have 2 select list drop downs. Select list A has 10 values (int). If a certain selection is made aka: a specific value, then I want to Select list B to be hidden. Right now I have the hiding functionality, if I use multiple "||" or statements, but this is messy and no good practice. How do I check if a specific value is chosen without using a bunch of or statements?
Current Code (working but ugly):
$('#status').change(function(){
let $appStatus = $('#status').val();
if($appStatus == 400 || $appStatus == 606 || $appStatus == 620 || $appStatus == 700 || $appStatus == 1000 || $appStatus == 1020){
console.log(true);
$reasonNoHire.hide()
}else{
console.log(false);
$reasonNoHire.show();
}
});
Other code I have tried by always returns false
//Brought back depending on what the user chooses in Selectlist A
let $appStatus = $('#status').val();
let valArray = [400, 606, 620, 700, 1000, 1020];
if(valArray.includes($appStatus)){
console.log(true);
$reasonNoHire.hide()
}else{
console.log(false);
$reasonNoHire.show();
}
});