Liliana797979

modern time of hash tag - fundamentals

Jul 25th, 2021
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function modernTimesOfHashTag(str) {
  2.   str = str.split(' ');
  3.   for (const currentWord of str) {
  4.     if (currentWord[0] === '#' && currentWord.length > 1) {
  5.       let isValid = false;
  6.       let currentWordArray = currentWord.slice(1).split('');
  7.       currentWordArray.every(char => {
  8.         if ((char.charCodeAt(0) >= 65 && char.charCodeAt(0) <= 90) || (char.charCodeAt(0) >= 97 && char.charCodeAt(0) <= 122)) {
  9.           return isValid = true;
  10.         } else {
  11.           return isValid = false;
  12.         }
  13.       });
  14.       if (isValid) {
  15.         console.log(currentWord.slice(1));
  16.       }
  17.     }
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment