Skip to content

Commit 09f3e43

Browse files
committed
inicial commit
0 parents  commit 09f3e43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1479
-0
lines changed

arrays/adicionar-notas.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const notas = [4, 7, 9];
2+
3+
notas.push(10);
4+
5+
const media = (notas[0] + notas[1] + notas[2] + notas[3]) / notas.length;
6+
7+
console.log(media);

arrays/array-de-arrays.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const alunos = ['João', 'Juliana', 'Caio', 'Ana'];
2+
const media = [10, 8, 7.5, 9 ];
3+
4+
const lista = [alunos, media];
5+
6+
console.log(`a aluna da posição 1 eh: ${lista[0][1]}
7+
e sua nota eh: ${lista[1][1]}`);
8+

arrays/array-map.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const arrayNums = [1, 2, 3, 4]
2+
3+
function multiplicaPorDez(numero){
4+
return numero * 10;
5+
}
6+
7+
const novoArray = arrayNums.map(multiplicaPorDez);
8+
9+
console.log(novoArray);

arrays/atualizar-lista.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const estudantes = ['João', 'Ana', 'Caio', 'Lara', 'Marjorie', 'Leo'];
2+
3+
estudantes.splice(1, 2, 'Rodrigo');
4+
5+
console.log(estudantes);

arrays/calculo-media.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const notas = [10, 6.5, 8, 7.5];
2+
const media = (notas[0] + notas[1] + notas[2] + notas[3]) / notas.length;
3+
console.log(media);
4+
5+
//usando propriedade lenght para mostrar qnts itens tem no arrays nums.
6+
const nums = [32, 45, 78];
7+
console.log(nums.length);

arrays/clonar.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const notas = [7, 7, 8, 9];
2+
const novaListaNotas = [...notas, 10];
3+
4+
console.log(notas);
5+
console.log(novaListaNotas);
6+
7+
//usando o operador de espalhamento não precisa do push pois após o array acrescenta o contéudo.
8+
//antes:
9+
/*
10+
const notas = [7, 7, 8, 9];
11+
const novaListaNotas = [...notas];
12+
13+
novaListaNotas.push(10);
14+
15+
console.log(notas);
16+
console.log(novaListaNotas);
17+
*/

arrays/desestruturar.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const alunos = ['João', 'Juliana', 'Caio', 'Ana'];
2+
const medias = [10, 8, 7.5, 9];
3+
4+
const lista = [alunos, medias];
5+
6+
7+
function exibeNomeENota(aluno){
8+
if (lista[0].includes(aluno)){
9+
const [alunos, medias] = lista;
10+
const indice = alunos.indexOf(aluno);
11+
const mediaAluno = medias[indice];
12+
console.log(`${aluno} tem a media ${mediaAluno}.`);
13+
} else{
14+
console.log("Estudante não existe na lista.");
15+
}
16+
}
17+
18+
exibeNomeENota('Juliana');
19+
exibeNomeENota('Vini');

arrays/dividir-array.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const estudantes = ['João', 'Juliana', 'Ana', 'Caio', 'Lara', 'Marjorie', 'Guilherme', 'Aline', 'Fabiana', 'André', 'Carlos', 'Paulo', 'Bia', 'Vivian', 'Isabela', 'Vinícius', 'Renan', 'Renata', 'Daisy', 'Camilo'];
2+
3+
const sala1 = estudantes.slice(0, estudantes.length / 2);
4+
const sala2 = estudantes.slice(estudantes.length / 2);
5+
6+
console.log(sala1, sala2);

arrays/excluir-elemento.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const notas = [3, 5.5, 9];
2+
3+
notas.pop();
4+
5+
console.log(notas);

arrays/filtrar.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const alunos = ['Ana', 'Marcos', 'Maria', 'Mauro'];
2+
const medias = [7, 4.5, 8, 7.5];
3+
4+
const tamanhoNome = alunos.filter((aluno) => {
5+
return aluno.length < 4;
6+
});
7+
8+
const reprovados = alunos.filter((_, indice) => {
9+
return medias[indice] < 7;
10+
})
11+
12+
console.log(tamanhoNome);
13+
console.log(reprovados);
14+
15+
//demarca um parâmetro com anderline (_) pra quando não vai utilizar no momento ele, então vai 'pular' e usar o seguinte.

arrays/for-classico.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const notas = [10, 8.5, 5, 6.5, 8, 7.5];
2+
3+
for (let indice = 0; indice < notas.length; indice++){
4+
console.log(`${indice} -> ${notas[indice]}`);
5+
}

arrays/for-matriz.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const notas1 = [10, 6.5, 8, 7.5];
2+
const notas2 = [9, 6, 6];
3+
const notas3 = [8.5, 9.5];
4+
5+
const notasGerais = [notas1, notas2, notas3];
6+
7+
let media = 0
8+
9+
for (let i = 0; i < notasGerais.length; i++){
10+
for (let j = 0; j < notasGerais[i].length; j++){
11+
media += notasGerais[i][j] / notasGerais[i].length;
12+
}
13+
}
14+
15+
media = media / notasGerais.length;
16+
17+
console.log(media);

arrays/for-of.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const notas = [10, 6.5, 8, 7.5, 10, 10];
2+
let somaDasNotas = 0;
3+
4+
for (let nota of notas){
5+
somaDasNotas += nota;
6+
}
7+
8+
console.log(somaDasNotas);

arrays/foreach.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const notas = [10, 6.5, 8, 7.5];
2+
let somaDasNotas = 0;
3+
4+
notas.forEach(function (nota){
5+
somaDasNotas += nota;
6+
})
7+
8+
const media = somaDasNotas / notas.length;
9+
10+
console.log(`a média das notas eh ${media}`);
11+
12+
/* outra forma mais clara pra representar o que acontece acima
13+
notas.forEach(somaDasNotas);
14+
15+
function somaDasNotas(nota){
16+
somaDasNotas += nota;
17+
}
18+
*/

arrays/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const arrayVazia = [,,,];
2+
3+
arrayVazia.push(50);
4+
5+
console.log(arrayVazia);
6+
console.log(arrayVazia.length);
7+
console.log(arrayVazia[3]);

arrays/juntar-salas.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const salaJS = ['Evaldo', 'Camis', 'Mari'];
2+
const salaPython = ['Ju', 'Leo', 'Raquel'];
3+
4+
const salasUnificadas = salaJS.concat(salaPython);
5+
6+
console.log(salasUnificadas);

arrays/map-string.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const nomes = ["ana Julia", "Caio vinicius", "BIA silva"];
2+
3+
const nomesPadronizados = nomes.map((nome) => nome.toUpperCase());
4+
5+
console.log(nomesPadronizados);

arrays/map.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const notas = [10, 9.5, 8, 7, 6];
2+
3+
const notasAtualizadas = notas.map((nota) => nota + 1 >= 10 ? 10 : nota + 1);
4+
5+
console.log(notasAtualizadas);
6+
7+
8+
9+
//acima temos uma arrow function, que seria a mesma coisa que o exemplo abaixo (porém esse incluindo a function em si não eh a melhor forma)
10+
const notas2 = [10, 9.5, 8];
11+
12+
const notas2Atualizadas = notas2.map(function (nota){
13+
if(nota + 1 >= 10){
14+
return nota = 10;
15+
} else{
16+
return nota + 1;
17+
}
18+
})
19+
20+
console.log(notas2Atualizadas);

arrays/media-for.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const notas = [10, 6.5, 8, 7.5];
2+
let somaDasNotas = 0;
3+
4+
for (i = 0; i < notas.length; i++){
5+
somaDasNotas += notas[i];
6+
}
7+
8+
const media = somaDasNotas / notas.length;
9+
10+
console.log(`a soma das notas eh ${media}.`);

arrays/procurar-em-listas.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const alunos = ['João', 'Juliana', 'Caio', 'Ana'];
2+
const medias = [10, 8, 7.5, 9];
3+
4+
const lista = [alunos, medias];
5+
6+
7+
function exibeNomeENota(aluno){
8+
if (lista[0].includes(aluno)){
9+
const indice = lista[0].indexOf(aluno);
10+
const mediaAluno = lista[1][indice];
11+
console.log(`${aluno} tem a media ${mediaAluno}.`);
12+
} else{
13+
console.log("Estudante não existe na lista.");
14+
}
15+
}
16+
17+
exibeNomeENota('Juliana');
18+
exibeNomeENota('Vini');

arrays/reduce-estrutura.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const numeros = [43, 50, 65, 12]
2+
3+
const soma = numeros.reduce((acum, atual) => atual + acum, 0)
4+
5+
console.log(soma)

arrays/reduce.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const salaJS = [7, 8, 8, 7, 10, 6.5, 4, 10, 7];
2+
const salaJava = [6, 5, 8, 9, 5, 6];
3+
const salaPython = [7, 3.5, 8, 9.5];
4+
5+
function calculaMedia(listaNotas){
6+
const somaDasNotas = listaNotas.reduce((acumulador, nota) => {
7+
return acumulador + nota;
8+
}, 0);
9+
10+
const media = somaDasNotas / listaNotas.length;
11+
return media;
12+
}
13+
14+
15+
console.log(calculaMedia(salaJS));
16+
console.log(calculaMedia(salaJava));
17+
console.log(calculaMedia(salaPython));
18+
19+
//versão reduzida da função calculaMedia:
20+
/*
21+
const somaDasNotas = listaDeNotas.reduce((acumulador, nota) => acumulador + nota, 0);
22+
*/

arrays/set.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const nomes = ["Ana", "Clara", "Maria", "Maria", "João", "João", "João"];
2+
3+
const listaNomesAtualizado = [...new Set(nomes)];
4+
5+
console.log(listaNomesAtualizado);
6+
7+
8+
//O Set não tem acesso para usar métodos de arrays.
9+
//Mas criando ele usando operador de espalhamento eh possível utilizar.
10+
//Código acima simplificado, abaixo o original:
11+
/*
12+
const nomes = ["Ana", "Clara", "Maria", "Maria", "João", "João", "João"];
13+
14+
const nomesAtualizados = new Set(nomes);
15+
16+
const listaNomesAtualizado = [...nomesAtualizados];
17+
18+
console.log(nomesAtualizados);
19+
console.log(nomesAtualizados);
20+
*/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Usando VAR
2+
// se não declarar a variável area vai funcionar e aparecer mesmo assim no console.
3+
/*
4+
var altura = 5;
5+
var comprimento = 7;
6+
area = altura * comprimento;
7+
8+
console.log(area);
9+
var area;
10+
*/
11+
12+
// Usando LET
13+
// não pode declarar no final.
14+
/*
15+
let forma = "retângulo";
16+
let altura = 5;
17+
let comprimento = 7;
18+
let area
19+
20+
if (forma === "retângulo"){
21+
area = altura * comprimento;
22+
} else {
23+
area =(altura * comprimento) / 2;
24+
}
25+
26+
console.log(area);
27+
*/
28+
29+
//Usando CONST
30+
//
31+
32+
const forma = "triângulo";
33+
const altura = 5;
34+
const comprimento = 7;
35+
let area;
36+
37+
if (forma === "quadrado"){
38+
area = altura * comprimento;
39+
} else {
40+
area = (altura * comprimento) / 2;
41+
}
42+
43+
console.log(area);

declarando-variaveis/escopo.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
//JS lendo tudo e depois carregando, exibindo os dois valores
3+
let numero = 1;
4+
console.log(numero);
5+
6+
numero = 2;
7+
console.log(numero);
8+
*/
9+
10+
//Variável dentro e fora de escopo
11+
if (1 > 0) {
12+
let estudante = "Caroline";
13+
console.log(estudante);
14+
}
15+
16+
estudante = "Ana";
17+
console.log(estudante);

exercicios/lista01/ex01.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*1. Declare três variáveis diferentes (uma para cada tipo: string, número e booleano) e atribua valores a elas. Em seguida, exiba o tipo de cada variável no console.*/
2+
3+
const fruta = "morango";
4+
const num = 10;
5+
const bool = false;
6+
7+
console.log(typeof fruta);
8+
console.log(typeof num);
9+
console.log(typeof bool);

exercicios/lista01/ex02.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*2. Crie duas variáveis, uma contendo seu primeiro nome e outra contendo seu último nome. Em seguida, combine-as em uma terceira variável usando o operador + e em uma quarta variável usando template strings. Por fim, imprima os resultados obtidos no console.*/
2+
3+
const nome = "Dominike";
4+
const sobrenome = "Righi";
5+
const nomeSobrenome = nome + ' ' + sobrenome;
6+
const nomeCompletoTemplate = `${nome} ${sobrenome}`;
7+
8+
console.log(nome);
9+
console.log(sobrenome);
10+
console.log(nomeSobrenome);
11+
console.log(nomeCompletoTemplate);

exercicios/lista01/ex03.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*3. Declare duas variáveis, uma contendo um número e outra contendo uma string. Em seguida, combine-as em uma terceira variável usando template strings para montar uma frase e exiba o resultado no console.*/
2+
3+
const nome = "Dominike";
4+
const idade = 22;
5+
const eu = `Meu nome eh ${nome} e tenho ${idade} anos.`;
6+
7+
console.log(nome);
8+
console.log(idade);
9+
console.log(eu);

0 commit comments

Comments
 (0)