String
Part of the Fundamentals section of Coddy's JavaScript journey — lesson 6 of 77.
A char is a single character (For example: 1, 6, %, b, p, ., T, etc.) — note that char is used here as a conceptual term; JavaScript does not have a dedicated char type.
The string type consists of one or more chars — a string can be a single character or many characters combined.
To initialize a string value in a variable, enclose it within single or double quotation marks:
let s1 = 'This is a string'
let s2 = "This is also a string"In the above example, two string variables are initialized, named s1 and s2.
Challenge
BeginnerStore the string I am learning to code with Coddy! in a variable named coddy.
Be sure to store the exact string value with correct casing.
Cheat sheet
A char is a single character (e.g., 1, 6, %, b, p, ., T).
A string consists of multiple chars. Initialize strings using single or double quotation marks:
let s1 = 'This is a string'
let s2 = "This is also a string"Try it yourself
// Type your code below
let coddy = ?
// Don't change the line below
console.log(`coddy = "${coddy}"`)This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Type Coercion7Bill Split Calculator
Welcome MessageCalculating The Tip And Total2Variables
NumbersStringBooleanNaming ConventionsEmpty VariablesRecap - Initialize VariablesConstants3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsComparison OperatorsStrict vs Loose EqualityRecap - Simple Math6Basic IO
OutputOutput with VariablesType Conversion - Part 1Type Conversion - Part 2Recap - Till 120Recap - True or False