How can I get the first 3 words from a string and add them to the last 3 words of the same string and skip the text in the middle.
For ex.,
The string "I have something important to tell you guys"
The result should be the string "I have something tell you guys" (first 3 words and last 3 words)
My code:
let myString = "I have something important to tell you guys";
let myArray = "I have something important to tell you guys";
myArray = myArray.split(' ')
let firstThreeWords = myArray[0] + " " + myArray[1] + " " + myArray[2];
let lastThreeWords = ... //not sure what to put here
console.log(firstThreeWords + lastThreeWords)
I got the first 3 words but how can I get the last 3 words if we don't know the exact number of words in a string?