+ 2
Remove word and insert sentence in the words array
challenge is to replace words with matching sentence. Sentence will include words in order. ex: let wordsArray = ["hello", "javascript", "is","cool","&","sololearn","is","cool","hello","sololearn"]; let sentence = "is cool" //logic for updated array output: wordsArray = ["hello", "javascript", "is cool","&","sololearn","is cool","hello","sololearn]
4 Answers
+ 5
homework?
+ 3
Try to iterate through your array, then on each iteration, verify, if (array[i] + " " + array[i+1] == sentence), add sentence to output array, then skip array[i+1], else add the array[i] to the output array as usual. Hope it works :)
+ 1
Bit tricky
+ 1
@lpang I have tried it in this way, but I think this solution is not complete-
https://code.sololearn.com/W0NUXlJPBP3k