Programming foundations

Stage 1 · Lesson 2 of 10

Strings and template literals

Your first language

hold text and cannot be changed in place. So methods like toUpperCase(), trim(), replace() and slice() give you a new string instead. Get one character by position with s[0], or the last one with s.at(-1).

Get the length with s.length, which is a property (a stored value), not a method you call. Turn text into an array with split(","), and back into text with join(). Build output with template literals: text wrapped in backticks, with values dropped in like ${name} is ${age}.

They read far better than long chains of +. You will use all of this constantly later in the stage, when parsing input, reading and building messages.

Common trapforgetting to store the result: name.trim() on its own line changes nothing.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    The language itself, closures and async included, with runnable exercises per lesson

  • GuideFree
    JavaScript.info

    Ilya Kantor

    Free: Part 1 is the most complete modern JavaScript tutorial, with tasks per chapter

Practise

  • Small exercises in your language track, with free feedback from a human mentor

  • Foundations path: the JavaScript basics lessons and the exercises repo with tests

Keep handy

  • The JavaScript reference: look up every array and string method here

Mark this stage as not done?