Maratona de fragmentos de strings
Este desafio tem cinco exercícios curtos para ajudar você a praticar a habilidade de extrair fragmentos de strings. Confira os exemplos abaixo para ver visualmente como extrair fragmentos das strings. Boa sorte!
Exemplos
const s = "abcdefghijklmnopqrstuvwxyz"challenge1(s) ➞ "abcde"
// First 5 characters of the string.
challenge2(s) ➞ "vwxyz"
// Last 5 characters of the string.
challenge3(s) ➞ "zyxwvutsrqponmlkjihgfedcba"
// All characters in the string from back.
challenge4(s) ➞ "fedcba"
// First 6 characters in the string (start with 6th character and go backwards).
challenge5(s) ➞ "tvxz"
// From the final seven characters, return every other character, starting with the first of those seven.Observações
- Confira a aba Tests para ver mais exemplos.
- Consulte a aba Resources para obter mais informações sobre como aprender a extrair fragmentos de strings.
- Você pode usar métodos diferentes de
slice()conforme necessário para concluir alguns dos desafios. - Todos os casos de teste seguem o mesmo padrão de extração de fragmentos do exemplo acima.