Module lessons (2/4)
String methods
length, toUpperCase, includes, slice, split, replace: the methods you use every day.
What you'll learn in this lesson
- Take advantage of the main search and inspection methods (
includes,startsWith,endsWith,indexOf,length). - Extract and normalize user text with
slice,trim,toLowerCase/toUpperCase. - Split strings into arrays with
splitand reassemble them withjoin. - Understand why all string methods are non-mutant and require reassignment or chaining.
Overview
Strings in JavaScript are immutable: no method alters the starting string, but they all return a new string (or a boolean, an index or an array). This makes them ideal for building normalization pipelines by chaining multiple calls together.
Just like in array pipelines, you can break text with .split(), clean up the elements, and rejoin them without mutating the original text.
Sections covered in this lesson
- 1Mental model: non-mutant pipeline on strings
- 2Progressive examples
- 3Guided laboratory
- 4Check for understanding
Unlock "String methods" and the full JavaScript Course curriculum
length, toUpperCase, includes, slice, split, replace: the methods you use every day.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in JavaScript Course plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.