DEV Community

Danish Saleem
Danish Saleem

Posted on

2 1

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (1)

Collapse
 
sachinsapkota9879 profile image
sachin sapkota •

aaaaaaaaaaaaaa

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →