freeCodeCamp/guide/portuguese/certifications/javascript-algorithms-and-d.../basic-javascript/find-the-length-of-a-string/index.md

447 B

title localeTitle
Find the Length of a String Encontre o comprimento de uma string

Encontre o comprimento de uma string

As cordas têm um atributo (recurso) chamado 'comprimento'. Tudo o que você precisa fazer é marcá-lo após a string / variável.

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.