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
You should probably do some validations before you actually execute your function :
function trim(str) { if(typeof str !== 'string') { throw new Error('only string parameter supported!'); } return str.replace(/^\s+|\s+$/g,''); }