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!
7 ответов
+ 1
Md Shahriar Rahman
Add this line in print () function
document.write("<br>");
+ 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.
+ 1
Md Shahriar Rahman
Just do this nothing else
print() {
console.log("quot; + (this.words).join("quot;) + "quot;);
}
+ 1
I guess I went deeper without understanding the question clearly 😅
Thanks for the suggestions 🅰🅹 🅐🅝🅐🅝🅣
0
🅰🅹 🅐🅝🅐🅝🅣
Could you please explain the (this.words).join("quot;) part?
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.