DEV Community

Discussion on: Daily Challenge #182 - Arrh, grabscrab!

Collapse
 
fitsum profile image
fitsum • Edited

JavaScript

const grabscrab = (garble, dict) => {
  let results = [];
  dict.forEach(entry => {
    let points = 0; 
    entry.split('').forEach(letter => {
      if (garble.indexOf(letter) !== -1) {
        points++;
        if (points === entry.length) {
          results.push(entry);
          console.log(results)
        }
      }
    })
  })
  return results;
}