Write a function reverseWord(sentence, word) that returns the string sentence where every word equal to word is written backwards. All other words stay as they are.
sentence has words separated by single spaces, with no spaces at the start or the end and no punctuation. It can be empty.word is one word: at least one letter, no spaces.word changes. Case matters: 'amazon' is not 'Amazon'.word as a substring does not change: 'Amazonian' stays 'Amazonian'.sentence unchanged. An empty sentence gives ''.Tip: split the sentence into words, check each word, then join the words back.
reverseWord('I am working for Amazon', 'Amazon')Returns 'I am working for nozamA'
reverseWord('Amazon sells Amazonian books', 'Amazon')Returns 'nozamA sells Amazonian books'
Asked at Amazon · Source
reverseWord('I am working for Amazon', 'Amazon')'I am working for nozamA'reverseWord('I am working for Google', 'Amazon')'I am working for Google'Hidden tests run on Submit.