how to replace n in a string javascript from variable code example Example: javascript replace \n var r = "I\nam\nhere"; var s = r.replace(/\n/g,' ');