my_str = "\n\n Hello World \n\n\n";
my_str = my_str.replace(/^\s+|\s+$/g, '');
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
In the code snippet, we have a string my_str which contains line breaks on its start and end positions and we are removing them from the string.
Search Index Data (The code snippet can also be found with below search text)