JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = " \n this is a string \n \n \n"

console.log(str);
console.log(str.trim());