Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

To get length of string in javascript, use string.length instead of string use your string variable name it will return the number of character.

Today, I’m going to show you How do I get length of string in javascript, as mentioned above, I’m going to create a sample string variable then I will use the string length property to count number of letter.

Let’s start today’s tutorial on how do you get length of string in javascript.

Javascript get lentgh of the string

Here, we will do

  1. Create a sample string variable with data.
  2. Use .length property to count number character
// Create a sample string variable with data
let str = "infintbility";

// Use `.length` property to count number character
console.log("Length of string: ", str.length)

// Length of string:  12

Output

I hope it helps you, All the best đź‘Ť.