David David - 6 months ago 45
Javascript Question

New line is not working in Javascript

New line is not working in Javascript.

I am using new to add two string and second string should be in new line but

is not working.

My code is like

var s1 = "Hello";
var s2 = " My world";

var s3 = s1 +"\n"+ s2

output shuld be like :


My World

any suggetion. thanks for help


Use <b></b> to add the bold and <br> for the line break

var s1 = "Hello";
var s2 = "<b>My</b> world";

var s3 = s1 + "<br>" + s2;

document.getElementById("text").innerHTML = s3;
<p id="text"></p>