Need help with Function reverse Words(str_arg)

I need a function reverseWords(str_arg) –it will return a string containing the words of the string str_arg in reverse order. For example, if reverseChars(“The quick brown fox jumps over the lazy dog”) is called, the return value will be “dog lazy the over jumps fox brown quick The”.

Can anyone help me, pls?

Be warned! I have seen threads where students asked for answers and because they didn’t show what code they had written so far for themselves, other more knowledgeable members provided solutions that worked but were so advanced it would be obvious to a teacher that the student copy/pasted instead of making an effort to learn.

Mean? Look at it this way, if you don’t at least try to learn, it’s not fair to others and it’s not fair to you. No one is going to be there handing you code when it’s test time. If someone gives you code that gets you in trouble it will teach you a lesson you need to learn.


function reverseWords(str) {
  return str.split(' ').reverse().join(' ');
}

:slight_smile:

While we happily help people here learn about how to improve their scripting, when it comes to educational courses there are people here who get upset at “doing your own homework” so to speak.

If you haven’t received enough information from your tutor/lecturer/teacher, you really should approach them first about the information that you need to complete your assignment.

All the best with your studies. :tup:

Yes, this is correct.

As you’re also looking for a sentence-case function elsewhere, am I right to presume that you’re taking a programming course that involves these things?

Thnx for quick response)! And what i have to do after? Sorry, I’m totally beginner…