String Starts With in JavaScript

Level 138 keystrokes

startsWith() checks whether "Hello" begins with "He" and prints true.

JavaScript code

// startsWith() returns true if the string begins with the given text
// The check is case-sensitive: "Hello".startsWith("he") would be false
1console.log("Hello".startsWith("He"));

Output

true
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • "× 4
  • .× 2
  • (× 2
  • )× 2
  • ;× 1

More JavaScript examples at level 1

← JavaScript typing practice