Advertisement
simeonshopov

String Substring

May 12th, 2021
556
0
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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement