It’s because you can check if [‘learnJs’] == ‘learnJs’, but as soon as you add another id to the array then it’s actually testing the whole array against a single string and [‘learnJs’,‘learnJa’] == ‘learnJs’ ends up being false. To test if a string is in an array you need to use Array.indexOf() to test example if(checkboxIds.indexOf('learnJs'))
;
EDIT: Oh and you need to update your array when things are unchecked.