标签:
Write a reverseWords
function that accepts a string a parameter, and reverses each word in the string. Every space should stay, so you cannot usewords
from Prelude
.
Example:
reverseWords("This is an example!"); // returns "sihT si na !elpmaxe"
function reverseWords(str) { return str.split(‘ ‘).map(x=>x.split(‘‘).reverse().join(‘‘)).join(‘ ‘); }
标签:
原文地址:http://www.cnblogs.com/ycy1025/p/5471157.html