1. Strip whitespace
trim removes leading and trailing whitespace, leaving "hi".
" hi ".trim()Typorithm · easy
Step 1 of 8 · intro card
String Methods
trim strips surrounding whitespace; padStart and padEnd grow a string to a target length with a fill character. includes, startsWith, and toUpperCase test and normalize strings for reliable comparison.
trim removes leading and trailing whitespace, the first step in normalizing user input before comparing or storing it.
padStart(length, fill) and padEnd(length, fill) grow a short string to a fixed width — padStart(5, "0") turns "42" into "00042". The fill defaults to a space.
includes(sub), startsWith(prefix), and endsWith(suffix) return booleans for membership tests, while toUpperCase (and toLowerCase) normalize case so comparisons ignore it.
trim strips leading and trailing whitespace.
padStart and padEnd grow a string to a target length.
includes and startsWith return booleans for tests.
const clean = " hi ".trim()
const id = "42".padStart(5, "0")
const cell = "x".padEnd(5)
const has = "needle".includes("dle")
const starts = "needle".startsWith("nee")
const loud = "needle".toUpperCase()Connect each part of the code to the concept before you type.
trim removes leading and trailing whitespace, leaving "hi".
" hi ".trim()padStart adds the fill at the start until the string reaches length 5, giving "00042".
"42".padStart(5, "0")padEnd appends spaces (the default fill) until length 5, giving "x ".
"x".padEnd(5)includes returns true when the substring appears anywhere in the string.
"needle".includes("dle")startsWith returns true only when the string begins with the given prefix.
"needle".startsWith("nee")toUpperCase returns an upper-cased copy — handy for case-insensitive comparison.
"needle".toUpperCase()Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.