Navigate back to the homepage

How to find the length of a string in an array in Javascript??

Infinitbility
JavaScript
October 11th, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To find the length of a string in an array in javascript, use array[0].length it will return length of your first string of array.

Today, I’m going to show you How do I find the length of a string in an array in javascript, as mentioned above, I’m going to create a sample array of string variable then I will use the array index method to get the first string and check their length.

Let’s start today’s tutorial on how do you find the length of a string in an array in javascript.

Javascript gets the first letter of the string

Here, we will do

  1. Create a sample array string variable with data.
  2. Use array index and length to get length of array string
  3. Get length of string from the array of object
1// Create a sample array string variable with data.
2let arr1 = ["infintbility", "aguidehub", "sortoutcode"];
3
4// Use array index and length to get length of array string
5console.log("First Array string: ", arr1[0].length)
6console.log("Second Array string: ", arr1[1].length)
7console.log("Third Array string: ", arr1[2].length)
8
9// Get length of string from the array of object
10let arr2 = [
11 { name:"infintbility"},
12 { name:"aguidehub" },
13 { name: "sortoutcode" }
14];
15console.log("First Array object string: ", arr2[0].name.length)
16console.log("Second Array object string: ", arr2[1].name.length)
17console.log("Third Array object string: ", arr2[2].name.length)

Output

I hope it helps you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

How do you get the first letter of string Javascript?

An example of get the first letter of a string in javascript with the step-by-step guide.

October 10th, 2022 · 1 min read

How to find the first vowel in a string Javascript?

An example of making a string empty in javascript with the step-by-step guide.

October 9th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]