Sikau

JavaScript · Day 7 · about 25 min

Strings in depth

Length, upper case and picking out letters.

Text has superpowers

Ever seen a form say "Password must be at least 8 characters"? Or a name shown in CAPITALS? That's JavaScript working with strings. Today you'll learn how.

How long is it?

Every string knows its own length. Add .length after it:

console.log("momo".length);
console.log("Kathmandu".length);
console.log("dal bhat".length);

.length is a property — a fact about the string. No brackets needed; you're just reading information.

The rest of this lesson

  • Changing caseexplain
  • Picking out lettersexplain
  • Strings never changeexplain
  • Predict the outputpredict
  • Shout and countfill
  • Your turnwrite code
  • First letterwrite code
  • Challengechallenge
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript