Advertisement
Todorov_Stanimir

04. String Substring

Jul 19th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function stringSubstring(word, text) {
  2.     text = text.split(' ');
  3.     let foundWord = false;
  4.     for (currentWord of text) {
  5.         if (word.toLowerCase() === currentWord.toLowerCase()) {
  6.             foundWord = true;
  7.             break;
  8.         }
  9.     }
  10.     console.log(foundWord ? word : `${word} not found!`);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement