- A variable is a container for storing data values. E.g.,
let variable;
- Variables can store different data types including numbers and strings.
- A string is a series of characters or text. E.g.,
let name = "Mario";
- Strings are data types and are always enclosed in quotation marks (
""
or''
). - Strings and numbers are written differently. E.g.,
"seven"
vs7
. - Only the
+
operator can be used to concatenate strings.
- Basic Concatenation:
let first = "Maria"; let space = " "; let last = "Singh"; console.log(first + space + last); // "Maria Singh"
- Concatenation with Variables:
let food = "pizza"; let sentence = "My favorite food is " + food;
Happy coding! 😄