Does it matter if I use " vs '?

Question

Does it matter if I use " vs '?

Answer

The decision to use double ("") vs single (’’) quotes is largely one on preference. It is generally recommended to stick to using one or the other throughout your code for consistency. If you are trying to use one of the types of quotes in your string itself, then it is generally favorable to use the other quote to form the string. For example: "James said, 'Hello'" to use '' in your string and 'James said, "Hello"' to use "" in your string. An alternative way around this is to use escape sequences like so: "James said, \"Hello\"" or 'James said, \'Hello\''. You’ll learn more about escape sequences in later lessons.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.