Question #131   Submitted by Answiki on 08/31/2020 at 12:05:15 PM UTC

In JavaScript, how to insert a carriage return in a string?

Answer   Submitted by Answiki on 10/21/2021 at 06:53:36 PM UTC

In JavaScript, you can use the special character \n to insert a carriage return in a string:

const my_string = 'A string \n with two carriage \n return';

If you console.log(my_string) the previous string, the expected output is:

A string 
 with two carriage 
 return

3 events in history
Answer by Answiki on 10/21/2021 at 06:53:36 PM

In JavaScript, you can use the special character \n to insert a carriage return in a string:

const my_string = 'A string \n with two carriage \n return';

If you console.log(my_string) the previous string, the expected output is:

A string 
 with two carriage 
 return

Answer by Answiki on 08/31/2020 at 12:08:22 PM

In JavaScript, you can use the special character \n to insert a carriage return in a string:

const my_string = 'A string \n with two carriage \n return';

If you console.log(my_string) the string, the expected output is:

A string 
 with two carriage 
 return

Question by Answiki 08/31/2020 at 12:05:15 PM
In JavaScript, how to insert a carriage return in a string?
# ID Query URL Count

Icons proudly provided by Friconix.