Remove last line from string
javascript, jquery
Solution
Try:
if(x.lastIndexOf("\n")>0) {
return x.substring(0, x.lastIndexOf("\n"));
} else {
return x;
}
Problem
How do I remove the last line "\n" from a string, if I dont know how big the string will be? ``` var tempHTML = content.document.body.innerHTML; var HTMLWithoutLastLine = RemoveLastLine(tempHTML); function RemoveLastLine(tempHTML) { // code } ```