Add new line from js

You can add a new line in JavaScript using the following methods:

  1. Using the \n character:
    console.log("Hello" + "\n" + "World");

    This will output:

    Hello
    World
  2. Using the document.write() method:
    document.write("Hello<br>");
    document.write("World");

    This will output:

    Hello
    World
  3. Using the innerHTML property:
    var paragraph = document.createElement("p");
    paragraph.innerHTML = "Hello<br>World";
    document.body.appendChild(paragraph);

    This will output:

    Hello
    World
  4. Using the createElement() method and the appendChild() method:
    var paragraph = document.createElement("p");
    var textNode = document.createTextNode("Hello\nWorld");
    paragraph.appendChild(textNode);
    document.body.appendChild(paragraph);

    This will output:

    Hello
    World

    Note: The \n character is used to represent a new line in most programming languages, including JavaScript. However, in HTML, you need to use the <br> tag to create a new line.