Repository navigation
Expand file tree
/
Copy path07Strings.js
More file actions
executable file
·77 lines (54 loc) · 2.04 KB
/
Copy path07Strings.js
File metadata and controls
executable file
·77 lines (54 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
let str = "STRING_STRING"
//Retorna o Tamanho
let st1= str.length;
//Retorna o índice da primeira ocorrência
let st2 = str.indexOf("X");
//Retorna o índice da primeira ocorrência a partir de N
let st3 = str.indexOf("X", 1);
//Retorna o índice da última ocorrência
let st4 = str.lastIndexOf("X");
//Retorna o índice da última ocorrência N do fim ao início
let st5 = str.lastIndexOf("X",1);
//Retorna a posição da string procurado
let st6 = str.search("EFG");
//Retorna o caractere no índice especificado
let st7 = str.charAt(0);
let st8 = str[0];
//Retorna o unicode do caractere no índice especificado
let st9 = str.charCodeAt(0);
//Extrair uma parte(posição inicial e a posição final)
let st10 = str.slice(7, 13);
//Extrair uma parte(será contada a partir do final da string)
let st11 = str.slice(-12, -6);
//Extrair uma parte(especificando o comprimento)
let st12 = str.substr(0, 1);
//Substituir a primeira correspondência
let st13 = str.replace("W", "0");
//Substituir sem distinção entre maiúsculas e minúsculas
let st14 = str.replace(/z/i, "1");
//Substituir todas as correspondências
let st15 = str.replace(/X/g, "2");
//Converter para maiúscula
let st16 = str.toUpperCase()
//Converter para minúscula
let st17 = str.toLowerCase()
//Juntar
let st18 = str.concat(" ", "12345");
let st19 = " " + st15 + "@#$% "
//Remover espaço em branco
let st20 = st16.trim();
//Separar strings por caractere
let nome = "Carlos Felipe Ferreira "
let st21 = nome.split(" ")
console.log(st21)
//Template String(Literals)
nome = 'Jorge'
console.log(`
Oi ${nome},
tudo bem?
`)
console.log(`7 + 7 = ${7+7}`)
function calcular(x, y) {
return x * y
}
console.log(`A multiplicação de 8 * 8 é: ${calcular(8,8)}`)