forked from COLTEC-DAW/E05-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcoes.js
49 lines (48 loc) · 845 Bytes
/
funcoes.js
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
function min(a, b) {
if(a > b) {
return b;
}
else {
return a;
}
}
function max(a, b) {
if(a > b) {
return a
}
else {
return b;
}
}
function mod2(number) {
if (number % 2 == 0) {
return true;
}
else {
return false;
}
}
function mod(num, mod) {
if(num % mod == 0) {
return true;
}
else {
return false;
}
}
function countChars(frase, c) {
var re = /[\W_]/g;
frase = frase.toLowerCase().replace(re, '');
var ocorrencias;
for(let i = 0; i < frase.value.length()-1; i++) {
if (frase[i] == c) {
ocorrencias++;
}
}
return ocorrencias;
}
console.log(min(1, 10));
console.log(max(1, 10));
console.log(mod2(5));
console.log(mod(9, 3));
console.log (countChars("An na", 'a'));