How to Print a JavaScript Console Log in New Line

Javascript Console log New Line

Learn how to print a javascript console log in a new line with these simple steps:

1. Create your JS file

To create a JS file, we need to create a new document and save it with the “.js” extension, then the JS file will be created. You can name the document name however you like, ex: script.js. After saving your js file, your JS file will be displayed as the below image.

javascript console log new line

2. Using the console.log function

We can use the “console.log() function to display statements in the console. Inside these functions, we can pass any type of data like int, string, float, boolean, etc. You can see your output in the console itself. Follow this navigation to go console, “browser > right click > inspect > console”.

3. To print new line in javascript

We need to use the “\n ” character with double quotes to break a line in the console function. See the below code for example:

Ex:

console.log("Welcome \n");
console.log("To \n ");
console.log("Wonder Develop \n ");

Output:

K : javascript console log new line Learn how to print javascript console log in new line with these simple steps: 1. Create your JS file To create a javaScript file, we need to create a new document and save it with ".js" extension, then Javascript file will be created. You can name the document name however you like, ex: script.js. After saving your js file, your JS file will be displayed as below image. 2. Using console.log function We can use "console.log()" function to display statement in console. Inside these function, we can pass any type of data like int, string, float, boolean, etc. You can see your output in the console itself. Follow this navigation to go console, "browser > right click > inspect > console". We need to use "\n " character with double quotes to break a line and print on newline. See below code for example: console.log("Welcome \n"); console.log("To \n "); console.log("Wonder Develop \n "); Output:

Leave a Reply