O GoConqr está de visual novo! Conte para nós o que você achou.

Módulo 3 de 9 · Mídia

The length property and the split method

Kostas Diakogiannis

The length property and the split method

String methods and properties

Strings can have methods and properties exactly like objects. 

One of the commonest properties is the length property who returns the length of a string and how many characters this string is comprised of.

Another important method is the  split method. That splits actually a string into a smaller strings, and then it puts them as elements into an array. The new array is comprised of string elements and you can work individually with every substring. Split is a method, that means that you can also pass an argument and specify every WHICH character occurrence you want  to split your main string.

For example if you have a string like: let sentence = 'this sentence is nonsense',

sentence.split('') // Splits every single character into an array. ['t', 'h', 'i', 's', ' ', 's', 'e', 'n', 't'] etc.

sentence.split(' ') (with a space inside the argument. Splits every time it finds a space. So we end up with something like. ['this', 'sentence', 'is', 'nonsense'].

 

Find out all methods for strings here.

Instruções

Para avançar no curso, envie uma tentativa deste quiz. Você pode enviá-la depois da última pergunta.

Ir para o módulo escolhido

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?