ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

Break line in string #233

Closed tvcrawley closed 8 years ago

tvcrawley commented 8 years ago

Hi!

So I tried using \n, break line command, backslash, and concat. I also went to Joe for help and he couldn't figure it out either.

I expected the text beginning with \" to be displayed on the next line.

This happens:

The link to my repo is https://github.com/Chibiania/game-lab/blob/master/script.js my question is about line 4.

jshawl commented 8 years ago

what if you replace textContent with innerHTML https://github.com/Chibiania/game-lab/blob/168741baeec88ebb25bd1d350be8b66382808f3a/script.js#L78

RobertAKARobin commented 8 years ago

Try \\n.

What's going on here is Javascript is trying to "escape" the characters -- for example, turn < into &lt;.

tvcrawley commented 8 years ago

*I changed textcontent to innerhtml but there is no difference

tvcrawley commented 8 years ago

Just got help from Matt.

The answer was +"
"+ with the innerhtml