javascript / beginner
Snippet
String Length Property
Every string in JavaScript has a 'length' property that automatically tells you how many characters (including spaces) are in that string.
snippet.js
1
2
3
4
const username = 'Coder123';const nameLength = username.length;console.log(nameLength); // 8
Breakdown
1
username.length
Accesses the built-in property that calculates the number of characters.
2
console.log(nameLength)
Prints the integer representing the total count of characters to the console.