2018-10-16 21:32:40 +05:30

508 B

title
title
Find the Length of a String

Find the Length of a String

Strings have an attribute (feature) called 'length'. All you have to do is tag it after the string / variable.

var str1 = "Hello";
var length1 = str1.length; // This returns 5

var length2 = " Camper".length; // This returns 7 because the space is counted as one character.