trim the input string in javscript

get rid of leading and trailing whitespaces