js remove last newlien code example
Example: javascript remove final newline from string
// Remove the trailing newline(s) from a string
str.replace(/\n*$/, "");
// Remove the trailing newline(s) from a string
str.replace(/\n*$/, "");