Template Literals & Common String Operations
Use template literals and essential string methods; quick tour of numbers and Date basics.
Template Literals & Common String Operations is a free JavaScript Academy lesson on CoddyKit. This is lesson 1 of 3. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, and your progress syncs across the web and the CoddyKit app. The JavaScript Academy course includes 3 lessons in total.
Intro
Goal: Format text with template literals and use simple string methods. Then see a quick intro to numbers and dates.
- Template literals
- Common string ops
- Safe rounding
- Date basics

Template literals basics
Use backticks and ${} to insert values directly. Multi-line text is easy too.
// Template literals use backticks and ${}
// They support variables, expressions, and multi-line text
const name = "Ayla";
const score = 7;
const msg = `Hello, ${name}! Your score is ${score * 10}.`;
console.log(msg);
const lines = `Line 1
Line 2`;
console.log(lines);

String methods tour
Practice length, trim, toUpperCase, includes, indexOf, slice.
// Common string methods on a small example
const title = " JavaScript Basics ";
console.log("Length:", title.length);
console.log("Trim:", title.trim());
console.log("Upper:", title.toUpperCase());
console.log("Includes JS:", title.includes("JavaScript"));
console.log("Index of B:", title.indexOf("B"));
console.log("Slice 2..6:", title.slice(2, 6));

Concise formatting
Templates are shorter and easier to read than long + chains.
// Concatenation with + versus template literals
const user = "Mina";
const points = 12;
const viaPlus = "User: " + user + ", Points: " + points;
const viaTpl = `User: ${user}, Points: ${points}`;
console.log(viaPlus);
console.log(viaTpl);

Rounding basics
Use Math.round, floor, ceil for integers. toFixed returns a string with a fixed number of decimals.
// Numbers: integers, floats, and rounding helpers
const price = 4.35;
const qty = 3;
const total = price * qty;
console.log("Total raw:", total);
console.log("Math.round:", Math.round(total));
console.log("Math.floor:", Math.floor(total));
console.log("Math.ceil:", Math.ceil(total));
// toFixed returns a string with fixed decimals
console.log("toFixed(2):", total.toFixed(2));

Date quick tour
Create a Date with new Date(). Read parts with getters and print ISO for a standard format.
// Date basics: now, parts, and ISO output
const now = new Date();
console.log("Now:", now.toString());
console.log("Year:", now.getFullYear());
console.log("ISO:", now.toISOString());

Template literal quiz
Quick check: Backticks and ${}.

Recap
Recap: You used template literals, practiced key string methods, rounded numbers safely, and created/printed dates.

Learn JavaScript with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 59
- Lessons
- 200
Frequently Asked Questions
Is the “Template Literals & Common String Operations” lesson free?
Yes — any 3 lessons of the JavaScript Academy learning path, including “Template Literals & Common String Operations”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The JavaScript Academy course includes 3 lessons in total.
What will I learn in “Template Literals & Common String Operations”?
Use template literals and essential string methods; quick tour of numbers and Date basics. You practise JavaScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start JavaScript Academy?
No prior experience is required. JavaScript Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 3.
How long does the “Template Literals & Common String Operations” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this JavaScript Academy lesson?
Yes. Every JavaScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Template Literals & Common String Operations
- Numbers — Integers vs Floats & Math Essentials
- Dates — Basics, Time Zones, Intl.DateTimeFormat