I\'m using the below code to try to trim the string in Javascript but am getting the error mentioned in the title:
function trim(str) { return str.replac
Replace wouldn't replace numbers. It replaces strings only.
This should work.
function trim(str) { return str.toString().replace(/^\s+|\s+$/g,''); }
If you only want to trim the string. You can simply use "str.trim()"