Using break tag
document.write(" Hello World! <br/> Hello World!"); /* Output: Hello World! Hello World! */
In the above JS code, we have some text inside the document.write() function for printing. Here, I want to split the word, we cannot use ‘\n’ comment because the newline comment is working only console.log() funciton. So, we can use HTML break tag <br/>. You know that the break tag breaks or split the line. See the above output the word is successfully split. Similarly, we can perform breaking the line in many ways.
document.write(" Hello World!") document.write(" Hello World!") /* Output: Hello World!Hello World! */
Newline ‘\n’ Comment
console.log("Hello World! \n Hello World!");
Here, we can use ‘\n’ newline comment to split the line. But this newline comment works only in double quotes and only for console.log method.