DEV Community

Danish Saleem
Danish Saleem

Posted on

What are Multi-line Programs in JavaScript

You already know how to write simple single-line JavaScript programs that output a line of text to the console. This is an achievement in itself, but real programs contain a significant numbers of lines: from ten and hundreds for small scripts to serveral thousand for large projects. After reading this post, you will be able to write programs that can output several lines of text into the console at once.

Example

Let's start with an example of such scripts. The following code prints exactly three lines of text, each from a new line:

console.log("I");
console.log("know");
console.log("JavaScript");
Enter fullscreen mode Exit fullscreen mode

A line break can also be done using the symbol \n:

console.log("I\nknow\nJavaScript");
Enter fullscreen mode Exit fullscreen mode

The output of these two code samples will be the same:

```Plain Text
I
know
JavaScript




Try [running](https://replit.com/languages/javascript) these scripts yourself to see that it works.

## Empty Line

The `console.log` function also allows you to output an empty line without any information in it:



```JavaScript
console.log("I");
console.log();
console.log("know");
console.log();
console.log("JavaScript");
Enter fullscreen mode Exit fullscreen mode

Here's the output:

```Plain Text
I

know

JavaScript




---

### Let's connect 💜

You can connect with me on [Twitter](https://twitter.com/MrDanishSaleem), [LinkedIn](https://linkedin.com/in/mrdanishsaleem), [GitHub](https://github.com/mrdanishsaleem/), [Discord](https://discord.com/users/890596597610737774/)

---

### Support me 🤝

You can support me on [Buy Me a Coffee](https://www.buymeacoffee.com/mrdanishsaleem)
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
sachinsapkota9879 profile image
sachin sapkota

aaaaaaaaaaaaaa