You’ll learn what a JavaScript string holds, how it becomes bytes, and how regular expressions match Unicode. Your project is a payments team’s branch-name helper, ported from Python.
Here’s a first taste. In Python, a short helper builds a branch name from a ticket’s key and title, and keeps its first 16 characters:
def branch_name(key, title, limit=16):
name = f"{key}-{title}".lower()
return name.replace(" ", "-")[:limit]
title = "Zoë's 😀 refund fix"
print(branch_name("PAY-2401", title))
Zoë’s emoji is the 16th character, and Python prints it whole:
pay-2401-zoë's-😀
The JavaScript port uses .slice() with the same 16:
function branchName(key, title, limit = 16) {
const name = `${key}-${title}`.toLowerCase();
return name.replace(/ /g, "-").slice(0, limit);
}
const title = "Zoë's 😀 refund fix";
console.log(branchName("PAY-2401", title));
The emoji is gone:
pay-2401-zoë's-�
In its place, a question mark in a diamond stands in for broken text. The next lesson shows why.
Titles typed in Lisbon and Tokyo give the helper three problems. Zoë’s emoji gets cut. Two café titles that look the same, both for ticket PAY-2402, give two branch names:
pay-2402-café-re
pay-2402-café-r
And the team’s git host refuses names over 32 bytes. The team lead’s full Python copes, with len(),
unicodedata.normalize() and .encode("utf-8"), and you’ll port that care to JavaScript.
By the end of this course, you’ll be able to:
- Tell code units from code points, and walk a string by code point with
for...ofand.codePointAt() - Compare look-alike text with
.normalize(), and count what a reader sees withIntl.Segmenter - Encode text to UTF-8 bytes with
TextEncoder, and work withUint8Arrayviews and copies - Match Unicode with the
uandvflags, look behind and ahead, and scan with theyflag - Rebuild the team’s branch-name helper in JavaScript, matching its Python’s output
In Python, you only need to know str and bytes, encodings, unicodedata.normalize() and re
lookarounds. In JavaScript, you only need to know regular expressions with flags and named groups, and
iterating with spread and for...of.
You’ll need Node 26 or later installed, and no packages. The examples use Node 26 and Python 3.15.
The course mixes short videos with text lessons and exercises. Every video has a summary below it. A project video rebuilds the helper, and a quiz and a summary close the course.
Next up: Counting What a String Really Holds, where you find out what length counts, and why the emoji
broke.