+ 2

\n doesn't work

I'm messing around on javascript, and I find that \n and <br> do not work. what do I use to start a new line? thank you for any comments yall leave

25th Jul 2017, 5:56 PM
Thomas Gordon
11 Réponses
+ 3
To see the new line in html you would use <br>. To see the new line in things like the console, use \n. (Anything that isn't rendered by the html page). Can I see your code that has both not working? Perhaps your browser is not updated?
25th Jul 2017, 6:10 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
That's fine we all start somewhere, I think I was around 15 when I was first introduced to programming. I had absolutely no idea what was going on lol. \n is actually by itself NOT a statement. To simplify this for you, it is something that goes inside a string which will say to move to the next line. So your code could be like this: var x = 10; document.write(x + "\n"); That will be how it's properly used. If that doesn't work, use "<br>" instead of "\n". But keep the + !
25th Jul 2017, 6:22 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
what is your browser ? try \r\n
25th Jul 2017, 6:09 PM
nadz
nadz - avatar
+ 2
@josh no heh, I'm actually Atheist (or agnostic-atheist, not sure what people call it anymore). Originally I was planning on creating motivational/inspirational videos on Youtube so came up with this as a name. Although, I never really followed through (Made some, but they weren't great so I removed them). I still kept the name though. It still fits well anyway! 😜
25th Jul 2017, 7:48 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Can you provide a link to the code?
25th Jul 2017, 6:08 PM
josh mizzi
josh mizzi - avatar
+ 1
wow thx. yeah i really don't know what I'm doing. I'm also trying to learn linux, which is very different, but I like JS language more. I am happy to get a sentence on the output without screwing it up, so anything yall say will help. thank you
25th Jul 2017, 6:25 PM
Thomas Gordon
+ 1
Since you are using the Document.write() nethod, which injects into the HTML document, you will probably want to use <BR />. Your code should look like document.write(x + "<BR />") ; PS don't worry about being new, young and not knowing stuff you have plenty of time to learn. 😃
25th Jul 2017, 7:38 PM
josh mizzi
josh mizzi - avatar
+ 1
@Restoring faith, are you a Christian?
25th Jul 2017, 7:43 PM
josh mizzi
josh mizzi - avatar
+ 1
OK just wondering because I am.
25th Jul 2017, 7:50 PM
josh mizzi
josh mizzi - avatar
0
I was using the JS that came with this app. var x = 10; document.write(x); \n; var y = x + 10; document.write(y) I would like to say I am very new to all this. I'm just a 15 year old kid looking to learn the basics. I'm pretty much a super noob. but yeah there's my code if I did something wrong I'm happy to hear it. thx yall
25th Jul 2017, 6:16 PM
Thomas Gordon
0
I am a Pentecostal Christian.
25th Jul 2017, 9:39 PM
Thomas Gordon