请实现一个函数,把字符串中的每个空格替换成”%20”。
/** * @param {string} s * @return {string} */ var replaceSpaces = function(str) { return str.replace(/\s/g, '%20'); };