simeonshopov

String Substring

May 12th, 2021
475
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(searched, text) {
  2.   let found = false;
  3.  
  4.   for (const word of text.split(' ')) {
  5.     if (word.toLowerCase() === searched) {
  6.       found = true;
  7.       break;
  8.     }
  9.   }
  10.   (found) ? console.log(`${searched}`) : console.log(`${searched} not found!`);
  11. }
RAW Paste Data