Why does my Javascript trim Function not work?
问题 I am using this function to build a pig latin translator and seem to have everything figured out except for the .trim() part. What should I do different? function ParseText() { var myText = "asdf\n hat\n cat dog\n apple"; var lines = myText.split("\n"); var results = ""; for (var i = 0, len = lines.length; i < len; i++) { lines[i].trim(); var words = lines[i].split(" "); for (var j = 0, lenght = words.length; j < lenght; j++) { var word = words[j]; if (word.charAt(0) == "a" || word.charAt(0)