Coming soon - Get a detailed view of why an account is flagged as spam!
view details
1
Complete Newbie JavaScript Question About \n [Javascript]
Post Flair (click to view more posts with a particular flair)
Author Summary
darkeefrostee is in javascript
Post Body

Ok, so I am just learning javascript and the lessons that I have been using have been having me work in the chrome console on about:blank. That is all fine and good. I am having some issues with line breaks.

var greeting3 = 'Don\'t forget to grab the newspaper\n on your way out. You are going to be\n on the bus for a long time because of traffic.';

I am trying to get this with the line breaks in the appropriate place. I run greeting3 and get this:

greeting3
"Don't forget to grab the newspaper\n on your way out. You are going to be\n on the bus for a long time because of traffic."

Obviously I want this:

greeting3
"Don't forget to grab the newspaper 
on your way out. You are going to be
on the bus for a long time because of traffic."

What am I doing wrong? The dude I am following in the lesson seems to have no problem. I have even copy and pasted his text into my console and receive the same issue-- so that eliminated something that I may be typing wrong. Please try to ELI5 this lmao. Thanks if u made it this far !

Author
Account Strength
100%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
10,620
Link Karma
5,910
Comment Karma
4,337
Profile updated: 1 week ago
Posts updated: 2 months ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago