+ 3

Problem, creating a new line using "\n" is not working in javascript !!

https://code.sololearn.com/WR1EPX8IwGI9/?ref=app

1st Feb 2018, 8:03 PM
Anas Alrayes
Anas Alrayes - avatar
7 Answers
+ 4
use <br> instead document.write("first line <br>this is a new line");
1st Feb 2018, 8:23 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
Nope be doesn’t work
1st Feb 2018, 8:22 PM
Ole113
Ole113 - avatar
1st Feb 2018, 8:44 PM
Michael55555
Michael55555 - avatar
+ 2
@Tony Isotalo is right, but some browsers do not yet accept the <br> style and will still require the ending slash used in self-closing HTML elements like <br /> Just tested with your code above and this works fine.
1st Feb 2018, 9:47 PM
Tom Shaver
Tom Shaver - avatar
+ 2
@Martin Taylor yeah thank you, it makes sense now, i was just confused because you can't run a code in javascript without using html in sololearn. so it works if it's only javascript, right ?
1st Feb 2018, 9:59 PM
Anas Alrayes
Anas Alrayes - avatar
+ 1
Br
1st Feb 2018, 8:22 PM
Ole113
Ole113 - avatar
- 1
I'm not sure yet but I should like so /n
1st Feb 2018, 8:22 PM
Святик
Святик - avatar