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.
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: