0

Hi guys! I have a little doubt here...Do you think you can help?

https://code.sololearn.com/WLloZ5xMJJmi/?ref=app I want to print 3 lines in the document. But as you see, they all get printed on a single line. I've tried adding <br> and \n both...but maybe I'm making some mistakes. Again...if I try to print them on the console, each word gets printed on a new line. How do I fix that again? Thanks in advance!

4th May 2021, 9:16 AM
Md Shahriar Rahman
Md Shahriar Rahman - avatar
7 ответов
+ 1
Md Shahriar Rahman Add this line in print () function document.write("<br>");
4th May 2021, 9:36 AM
A͢J
A͢J - avatar
+ 1
Md Shahriar Rahman Btw why you are printing each word of a string. You have to join string with $ and then print that string. You jave 3 string so you have to print 3 string only.
4th May 2021, 9:38 AM
A͢J
A͢J - avatar
+ 1
Md Shahriar Rahman Just do this nothing else print() { console.log("
quot; + (this.words).join("
quot;) + "
quot;); }
4th May 2021, 9:41 AM
A͢J
A͢J - avatar
+ 1
I guess I went deeper without understanding the question clearly 😅 Thanks for the suggestions 🅰🅹 🅐🅝🅐🅝🅣
4th May 2021, 9:42 AM
Md Shahriar Rahman
Md Shahriar Rahman - avatar
0
🅰🅹 🅐🅝🅐🅝🅣 Could you please explain the (this.words).join("
quot;) part?
4th May 2021, 9:48 AM
Md Shahriar Rahman
Md Shahriar Rahman - avatar
0
Md Shahriar Rahman join() function add separator between each words in an array. So here (this.words) is an array and $ is a separator. Separator can be anything means it can be any special character or any word even a number also.
4th May 2021, 10:08 AM
A͢J
A͢J - avatar