Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
MUZ140845 Motion Kativhu
9,585 Pointsusing (" ") and (' ') on a variation does it make an difference?
can this make n difference when cording in javascript var visitorName= prompt ( "what is your name?"); and var visitorName= prompt ( 'what is your name?'); my ? is on (' ') and(" ")
2 Answers
Ezekiel dela Peña
6,231 PointsWell you see there's really no particular difference between the two. It is most likely depends on what your coding style is example
I use (" ") for strings and I use (' ') for smaller strings or char.
This can also be used to escape some cases. example will be:
"where you want double quotes to appear inside the string (e.g. for html attributes) without having to escape them, or vice versa" -reference to stackoverflow (don't know how to explain this case properly so yeah I need to google it for best possible explanation.)
Jeff Everhart
21,732 PointsEzekiel is right. Most of the time it is preference unless you are trying to write a string that contains quotation marks, then you will need to use both:
var string = '<h1 class="heading">My Site</h1>';