JSFiddle - React, Tailwind, and code Playground

by Janaka_Ravindra

JavaScript

var words = ['get', 'help', 'set', 'moon', 'class', 'code'];

var letter = 'e';

function find(words, letter) {

  letter = letter.split(''); //get it to as  object the  we can use it in every method as follwing

  return words.filter(function(word) { //get pne buy one word in words array

    return letter.every(function(char) {
      return word.includes(char); // return word including the letter that you request
    });
  });
}

const output = find(words, letter);
console.log(output);