function stringTrimRight(str) {
  return str.replace(/\s+$/, "");
}
Trim whitespace from end of string.

@see testStringTrimRight();

@param {String} str  Input string.
@return {String}  Trimmed string.