Files
Randell Dawson 7164d9a797 fix(guide): Added solutions and some hints and problem explanations for curriculum related Guide articles being ported over to forum (#36545)
* fix: added info and solutions for stubs

* fix: made title match main header

* fix: removed wrong closing tag

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: added closing tag

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: corrected solution

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: changed verbiage

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: added code tags

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: added solution
2019-08-01 14:16:54 +02:00

859 B

title
title
Quoting Strings with Single Quotes

Quoting Strings with Single Quotes


Problem Explanation

String values in JavaScript may be written with single or double quotes, so long as you start and end with the same type of quote. Unlike some languages, single and double quotes are functionally identical in JavaScript.

"This string has \"double quotes\" in it"

The value in using one or the other has to do with the need to escape quotes of the same type. If you have a string with many double quotes, this can be difficult to read and write. Instead, use single quotes:

'This string has "double quotes" in it. And "probably" lots of them.'

Solutions

Solution 1 (Click to Show/Hide)
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';