FAQ: Data Types - Strings

This community-built FAQ covers the “Strings” exercise from the lesson “Data Types”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn How To Code

FAQs on the exercise Strings

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

How do i represent the numerical value 20 inside a string? (without it splitting into 2 & 0)

or is there no need to do so when using strings

What I understand is that you can´t use a numerical value inside a string because you are using it like a letter, it´s info not value.

In the Explanation it says “we surround strings with single ( '...' ) or double quotes ( "..." ).”
Am just wondering in what context/for what types of data a single versus double quote would be used?

1 Like

When you say that the letters are separate from each other, but form a word when using string. What do you mean?

Characters (alpha, punctuation, etc) when not given delimiters are treated as identifiers, operators, delimiters, etc. as the interpreter is able to discern their meaning. When written in quotation marks, the interpreter can immediately identify them as character string data. Strings do not get parsed for other program meaning. They are static in memory and in some languages, immutable.

While there are stylized forms of quotes available on many keyboards, the ones used by programs are the standard ' and " (single and double, usually found on the same key, shifting for the double).

Starting out, the most common usage of strings is in the assignment.

a = 'a single quoted character string'

b = "a double quoted character string"

Once we are used to the idea of character strings, we can drop the ‘character’ and just call them strings. In pretty well every language, strings are a built in type, String, or string, or str. Given their type, the language will have built in methods for working with the objects, which come early in any course.

Also of note,

c = `A JavaScript back-tick quoted character string`
1 Like