TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
JavaScript / Chapter 6 of 60~12 min • Beginner
Chapter 06JavaScript

Strings and template literals

Strings represent text such as a page title or a username. Methods like trim, includes and toLowerCase return new values rather than modifying the original string. Template literals use backticks and interpolation to build readable messages.

How it works

Step-by-step walkthrough

  1. Normalize a string
  2. Check for text
  3. Interpolate a message

Example

JavaScript
const title = '  TestingDocs  ';
const clean = title.trim();
console.log(`Page: ${clean}`);
console.log(clean.includes('Docs'));
Expected result: Page: TestingDocs, then true
💡 Point to remember
Remember that string comparisons are case-sensitive.

✎ Your practice task

Check whether clean starts with Testing.

Knowledge check

Which method removes surrounding whitespace?

🌐 Continue learning