I am working on a problem where I need to be able to reverse a sentence but only words that are greater than 4 can be reversed. the rest of the words must be the same as they are. I have tried to check to see if length is greater than 4 but that does not return the result I am looking for. All I need is to reverse any words that are greater than 4 in the sentence. Any help is greatly appreciated.
Edit: Here is the simple of what I know how to do. It reverses all of the sentence. I am sure that there needs to be some way to break apart each word and determine the length of the word and then bring the sentence back together, but I don't know how that would be done.
var sentence = "This could be the answer I need";
if (sentence.length > 4) {
console.log( sentence.split('').reverse().join(''));
}
Thank you