bhylu.com

Advertisements

JS String Methods

String methods help clean and reshape text. Chain them when each result is the input for the next step.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const entered = "  Repair Club  ";
const cleaned = entered.trim().toLowerCase();
console.log(cleaned);

What happens

The result is repair club without the outer spaces.