check array values and change input isCheck (function)

I store true checkbox values in an array,

then after getting the array I want to chanage the checkbox isChecked to true if the checkbox value was in the array,

here is the function :

put(array, checkbox){
    for(let ent of checkbox) {    
      for(let entery of array)  {
        ent.val === entery 
        ? ent.isChecked= true
        : ent.isChecked= false
      }
    }
  }

here how did I store checkbox :


  public home_category = [
    { val: 'غرفة  نوم', isChecked: false },
    { val: 'صالة', isChecked: false },
    { val: 'حوش', isChecked: false },
    { val: 'مجلس', isChecked: false },
    { val: 'غرفة سائق', isChecked: false },
    { val: 'مطبخ', isChecked: false },
    { val: 'ملحق خارجي', isChecked: false },
    { val: 'صالة طعام', isChecked: false },
    { val: 'مستودع', isChecked: false }
  ];

this function did not work :(



Read more here: https://stackoverflow.com/questions/65713710/check-array-values-and-change-input-ischeck-function

Content Attribution

This content was originally published by amina ibrahim at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: