Write a function reverseAndCapitalize(text) that returns the words of the string text in reverse order, and every word starts with a capital letter: 'India is great' becomes 'Great Is India'.
text are separated by one or more spaces. There can be spaces at the start and at the end. A word is any group of characters without spaces, so it can contain ' or -.'wORLD' becomes 'World'. Change the letter case with toUpperCase() and toLowerCase(); a digit stays as it is.''.You can split the string into words, reorder them and join them back.
reverseAndCapitalize('India is great')Returns 'Great Is India'
reverseAndCapitalize('hello WORLD')Returns 'World Hello'
reverseAndCapitalize(' one two ')Returns 'Two One'
Asked at EPAM · Source
reverseAndCapitalize('India is great')'Great Is India'reverseAndCapitalize('hello WORLD')'World Hello'reverseAndCapitalize('')''Hidden tests run on Submit.