implement String.prototype.trim()
2022年5月1日小于 1 分钟
implement String.prototype.trim()
Question
String.prototype.trim() is commonly used when processing strings.
It is very easy, can you implement your own one?
There are many ways to do it, can you think of different approaches?
Code
/**
* @param {string} str
* @return {string}
*/
function trim(str) {
// your code here
}