JSFiddle - React, Tailwind, and code Playground

by Edward Tanguay

HTML

<div id="content"></div>

JavaScript

let elemContent = document.getElementById('content');
let html = '';

const searchText = 'array to';







const titles = [
	'Tick variables',
	'How to loop through properties of Javascript object',
	'How to find the index of an object in an array based on one of its properties',
	'Arrow functions',
	'How to find the index of a specific item in an array',
	'How to use for/of to change the contents of objects in an array',
];
const searchTerms = searchText.split(' ');

let matchedTitles = [];
for(title of titles) {
  let matched = true;
  for(searchTerm of searchTerms) {
    if(!title.includes(searchTerm)) {
			matched = false;
      break;
    }
  }
  if(matched) {
  	matchedTitles.push(title);
  }
}

elemContent.innerHTML = matchedTitles.join('<br/>');