Created
April 1, 2020 09:59
-
-
Save nmquebb/b87094629bfb204f74685c20eaf58597 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createSentenceArray(str) { | |
| const arr = str.split(" "); | |
| const newArr = []; | |
| for (let index = 0; index < arr.length; index++) { | |
| const word = arr[index]; | |
| if (DO_YOUR_REGEX_THING) { | |
| // if it is a mention push a span | |
| newArr.push(<span>{word}</span>) | |
| } else { | |
| // if it isnt a mention comcatenate the last word | |
| // we looped over add the next word to it | |
| newArr(newArr[newArr.length] + " " + word) | |
| } | |
| } | |
| return newArr; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment