5. What's the difference between " and '?


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/5?curriculum_id=506324b3a7dffd00020bf661

I'm not stuck, exactly, but I was wondering why the strings in the name/number fields use " " and the ones in the address array use ' '. Does it matter? Will my code be ruined if I switch them out?


#2

No, there is no difference, both are valid, however if you want to use js in combination with html, and the html needs an attribute:

var str = '<div class="someclass" >hello</div>';

vs:

var str = "<div class=\"someclass\" >hello</div>";

which one is easier to read? The first one indeed. So ' and " might be the same, but for some cases you might need to think twice which to use