$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #84

What is the correct fix?

const list = ['a', 'b'];
if ('a' in list) {
  console.log('found');
}
  1. Test membership with list.includes('a')
  2. Test membership with list.contains('a')
  3. Change the array into a plain object
  4. Compare directly with list == 'a'
in tests keys ('0','1') on an array, not the values stored in it.
Play Problem Solving ▸