i want to only reverse word strings that are more than 5 letters but in my result even the three letter words are getting reversed, how do i fix this ?
i want to only reverse word strings that are more than 5 letters but in my result even the three letter words are getting reversed, how do i fix this ?
Top comments (2)
You are reversing the characters of the whole string, then reversing the words. The if statement has no effect because you are checking the length of original string every time (not the words).
Try this:
or this: