What a string is
A string is a piece of text: characters in a row, in order. You write one between double quotes "Hi", single quotes 'Hi', or backticks `Hi`. The quotes are not part of the text.
Characters by index
The engine stores the string "Ada" in name. Its three characters, A, d and a, sit in a row, in order, and each has a number called its index. Indexes start at 0, so A is at index 0.
name[0] reads the character at index 0 and gives a new string of one character, "A". name[2] would give "a", the last one. There is nothing at index 3, so name[3] gives undefined.
name.length is how many characters the string has: 3. The last index is always length minus 1, here 2. length is a number, not text, so n holds 3 with no quotes.
New strings from old
toUpperCase() is a method: a function that belongs to the string. It builds a new string, "ADA", and loud keeps it. name still says "Ada": a string never changes. Methods give you a new one.
With a string on either side, + joins text end to end. The number 3 is turned into the text "3" first, so the line gives "Ada has 3 letters". + adds no spaces: they are inside " has ".
Template literals
Backticks make a template literal. Each ${...} is a slot: JavaScript works out the value inside and puts its text there. ${name} becomes Ada and ${n} becomes 3: the same text as line 5, easier to read.
console.log prints msg, then msg === old. Two strings are equal when they have the same characters in the same order, so === gives true. The console shows: Ada has 3 letters true
What happens
// step 1/8 · text
string a piece of text: characters in order
write it "Hi" 'Hi' `Hi`
(the quotes are not part of the text)
type typeof "Hi" → "string"
empty "" has no characters
Drawing each character in its own box is a simplification: the engine decides how to keep the text in memory. What the language promises is the order, the indexes from 0 and the length. A JavaScript string is really a row of UTF-16 code units, and length counts those. Every letter here takes one, but some characters take two: "😀".length is 2.