diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8c47a27 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\script.js" + } + ] +} \ No newline at end of file diff --git a/Exercicios/10. array.map()/script.js b/Exercicios/10. array.map()/script.js index b6e4227..352e40a 100644 --- a/Exercicios/10. array.map()/script.js +++ b/Exercicios/10. array.map()/script.js @@ -5,4 +5,11 @@ const usuarios = [ {user:237, name: 'Mariana', idade:15 }, {user:238, name: 'Isis', idade:34 }, {user:239, name: 'Pietra', idade:23 } -] \ No newline at end of file +] + +const textoResultado = usuarios.map((participante) => { + return `Nome: ${participante.name}, Idade: ${participante.idade} ` +}); + +console.log(textoResultado) + diff --git a/Exercicios/10. array.map()/script2.js b/Exercicios/10. array.map()/script2.js new file mode 100644 index 0000000..a0bd9e2 --- /dev/null +++ b/Exercicios/10. array.map()/script2.js @@ -0,0 +1,33 @@ +const vencedores = [ +{ + nome : "Equipe Super", + pais : "Brasil" + +}, + +{ + nome: "Time Maximo", + pais: "EUA" +}, +{ + + nome: "Mega Grupo", + pais: "Canadá" + +} +]; + +const winners = vencedores.map((item) => { + return item.nome; + + +}); + +const paises = vencedores.map((item) => { + return item.pais + +}) + + +console.log(winners, paises); + diff --git a/Exercicios/10. array.map()/script3.js b/Exercicios/10. array.map()/script3.js new file mode 100644 index 0000000..1e07898 --- /dev/null +++ b/Exercicios/10. array.map()/script3.js @@ -0,0 +1,17 @@ +const usuarios = [ + {user:234, name: 'Marcia', idade:40 }, + {user:235, name: 'Lorena', idade:20 }, + {user:236, name: 'Patricia', idade:24 }, + {user:237, name: 'Mariana', idade:15 }, + {user:238, name: 'Isis', idade:34 }, + {user:239, name: 'Pietra', idade:23 } +] + +const resultadoPietra = usarios.map((users) => { + if (users.user === 239) { + return `Nome: ${users.name}, tem ${users.idade} anos` + } + +}) + +console.log(resultadoPietra); \ No newline at end of file diff --git a/Exercicios/11. array.forEach()/script.js b/Exercicios/11. array.forEach()/script.js index 9c1e191..e9144b3 100644 --- a/Exercicios/11. array.forEach()/script.js +++ b/Exercicios/11. array.forEach()/script.js @@ -1 +1,11 @@ const numbers = [65, 44, 12, 4, 68]; + +let sum = 0; + +numbers.forEach((numero) => { + sum += numero; + + +}); + +console.log (sum); \ No newline at end of file diff --git a/Exercicios/11. array.forEach()/script2.js b/Exercicios/11. array.forEach()/script2.js new file mode 100644 index 0000000..4c29ff9 --- /dev/null +++ b/Exercicios/11. array.forEach()/script2.js @@ -0,0 +1,17 @@ +const usuarios = [ + {user:234, name: 'Marcia', idade:40 }, + {user:235, name: 'Lorena', idade:20 }, + {user:236, name: 'Patricia', idade:24 }, + {user:237, name: 'Mariana', idade:15 }, + {user:238, name: 'Isis', idade:34 }, + {user:239, name: 'Pietra', idade:23 }, + {user:240, name:"Camila", idade: 29} +] + +let somaIdades = 0; +usuarios.forEach(function(itens) { + somaIdades += itens.idade; + +}) + +console.log(somaIdades); \ No newline at end of file diff --git a/Exercicios/12. array.filter()/script.js b/Exercicios/12. array.filter()/script.js index 612c5ae..134d55b 100644 --- a/Exercicios/12. array.filter()/script.js +++ b/Exercicios/12. array.filter()/script.js @@ -1 +1,2 @@ const ages = [32, 33, 16, 40, 2, 69]; + diff --git a/Exercicios/2. for/script.js b/Exercicios/2. for/script.js index 557d6fc..044e312 100644 --- a/Exercicios/2. for/script.js +++ b/Exercicios/2. for/script.js @@ -1 +1,5 @@ const listagemDeFrutas = ["Uva", "Banana", "Manga", "Cajá", "Pinha", "Maçã", "Melão"]; + +for (let index = 0; index < listagemDeFrutas.length; index++ ){ +console.log(listagemDeFrutas[index]) +} \ No newline at end of file diff --git a/Exercicios/4. array.push()/script.js b/Exercicios/4. array.push()/script.js index db2e01a..c1260c6 100644 --- a/Exercicios/4. array.push()/script.js +++ b/Exercicios/4. array.push()/script.js @@ -1 +1,4 @@ -const listagemDeFrutas = [ "Uva", "Banana", "Manga", "Cajá", "Pinha", "Maçã", "Melão"]; \ No newline at end of file +const listagemDeFrutas = [ "Uva", "Banana", "Manga", "Cajá", "Pinha", "Maçã", "Melão"]; + +listagemDeFrutas.push("Melancia", "Jaca", "Pêra", "Laranja"); +console.log(listagemDeFrutas.length); \ No newline at end of file diff --git a/Exercicios/5. array.pop()/script.js b/Exercicios/5. array.pop()/script.js index b6f649a..2eba309 100644 --- a/Exercicios/5. array.pop()/script.js +++ b/Exercicios/5. array.pop()/script.js @@ -7,4 +7,10 @@ const usuarios = [ {user:237, name: 'Mariana', idade:15 }, {user:238, name: 'Isis', idade:34 }, {user:239, name: 'Pietra', idade:23 } -] \ No newline at end of file +] + +const ultimosElementoListagem = listagemDeFrutas.pop(); +console.log(listagemDeFrutas); + +const usuariosPop = usuarios.pop(); +console.log(usuarios); \ No newline at end of file diff --git a/Exercicios/6. array.shift()/script.js b/Exercicios/6. array.shift()/script.js index b6f649a..da63da6 100644 --- a/Exercicios/6. array.shift()/script.js +++ b/Exercicios/6. array.shift()/script.js @@ -7,4 +7,11 @@ const usuarios = [ {user:237, name: 'Mariana', idade:15 }, {user:238, name: 'Isis', idade:34 }, {user:239, name: 'Pietra', idade:23 } -] \ No newline at end of file +] + +listagemDeFrutas.shift(); +console.log(listagemDeFrutas); + +usuarios.shift(); +console.log(usuarios); + diff --git a/Exercicios/7. array.unshift()/script.js b/Exercicios/7. array.unshift()/script.js index 8421f62..6a0e9f1 100644 --- a/Exercicios/7. array.unshift()/script.js +++ b/Exercicios/7. array.unshift()/script.js @@ -6,4 +6,15 @@ const usuarios = [ {user:237, name: 'Mariana', idade:15 }, {user:238, name: 'Isis', idade:34 }, {user:239, name: 'Pietra', idade:23 } -] \ No newline at end of file +] + +listagemDeFrutas.unshift("Laranja", "Goiaba"); +console.log(listagemDeFrutas); + +usuarios.unshift({ + user:233, + name: "Jaqueline", + idade: 36 +}); + +console.log(usuarios); \ No newline at end of file diff --git a/Exercicios/8. array.slice()/script.js b/Exercicios/8. array.slice()/script.js index 8421f62..f47c733 100644 --- a/Exercicios/8. array.slice()/script.js +++ b/Exercicios/8. array.slice()/script.js @@ -6,4 +6,10 @@ const usuarios = [ {user:237, name: 'Mariana', idade:15 }, {user:238, name: 'Isis', idade:34 }, {user:239, name: 'Pietra', idade:23 } -] \ No newline at end of file +] + +const selectedItens = listagemDeFrutas.slice(2,4); +console.log(selectedItens); + +const selectedUsers = usuarios.slice(2,5); +console.log(selectedUsers); \ No newline at end of file diff --git a/Exercicios/9. array.splice()/script.js b/Exercicios/9. array.splice()/script.js index 08107fd..e311dd9 100644 --- a/Exercicios/9. array.splice()/script.js +++ b/Exercicios/9. array.splice()/script.js @@ -6,4 +6,10 @@ const usuarios = [ {user:237, name: 'Mariana', idade:15 }, {user:238, name: 'Isis', idade:34 }, {user:239, name: 'Pietra', idade:23 } -] \ No newline at end of file +] + +countryList.splice(3,1,"Peru"); +console.log(countryList); + +usuarios.splice(3,1, {user:237, name:"Camila", idade: 29}); +console.log(usuarios); \ No newline at end of file diff --git "a/Exerc\303\255cio de Casa/README.md" "b/Exerc\303\255cio de Casa/README.md" index aa1bf90..4e80d64 100644 --- "a/Exerc\303\255cio de Casa/README.md" +++ "b/Exerc\303\255cio de Casa/README.md" @@ -92,7 +92,6 @@ Assim, vamos produzir uma nova versão do site previamente elaborado. 6. O livro adicionado permanecerá podendo ser deletado pelo usuário. -7. A informação de data de inserção deverá ser removida da listagem de livros.**Na listagem dos livros inseridos, deverá vir uma informação nova, denominada "Data da inserção", contendo a data e o horário em que o livro foi inserido no sistema**. 8. É preciso seguir a estrutura de repositório contida nessa pasta "Exercício de Casa". diff --git "a/Exerc\303\255cio de Casa/index.html" "b/Exerc\303\255cio de Casa/index.html" index e69de29..88e1d58 100644 --- "a/Exerc\303\255cio de Casa/index.html" +++ "b/Exerc\303\255cio de Casa/index.html" @@ -0,0 +1,56 @@ + + + + + + + + Biblioteca + + +
+

My Audible Books

+
+
+ +


+ +
+

+
+

+
+

+
+ +
+
+

+ +
+ +
+ + + + + + + + + + + + + + + + + +
AutorTítuloISBNData da PublicaçãoPáginasData de inserção
+ + + + + + \ No newline at end of file diff --git "a/Exerc\303\255cio de Casa/script/script.js" "b/Exerc\303\255cio de Casa/script/script.js" index 68f1d0b..c749c91 100644 --- "a/Exerc\303\255cio de Casa/script/script.js" +++ "b/Exerc\303\255cio de Casa/script/script.js" @@ -5,6 +5,7 @@ let books = [ subtitle: "A Modern Introduction to Programming", author: "Marijn Haverbeke", published: "2014-12-14T00:00:00.000Z", + pages: 121, }, { isbn: "9781449331818", @@ -12,6 +13,7 @@ let books = [ subtitle: "A JavaScript and jQuery Developer's Guide", author: "Addy Osmani", published: "2012-07-01T00:00:00.000Z", + pages: 12, }, { isbn: "9781449365035", @@ -19,6 +21,7 @@ let books = [ subtitle: "An In-Depth Guide for Programmers", author: "Axel Rauschmayer", published: "2014-02-01T00:00:00.000Z", + pages: 20, }, { isbn: "9781491950296", @@ -26,6 +29,7 @@ let books = [ subtitle: "Robust Web Architecture with Node, HTML5, and Modern JS Libraries", author: "Eric Elliott", published: "2014-07-01T00:00:00.000Z", + pages: 14, }, { isbn: "9781593277574", @@ -33,23 +37,75 @@ let books = [ subtitle: "The Definitive Guide for JavaScript Developers", author: "Nicholas C. Zakas", published: "2016-09-03T00:00:00.000Z", + pages: 32, }, { isbn: "9781491904244", title: "You Don't Know JS", author: "Kyle Simpson", published: "2015-12-27T00:00:00.000Z", + pages: 35, }, { isbn: "9781449325862", title: "Git Pocket Guide", author: "Richard E. Silverman", published: "2013-08-02T00:00:00.000Z", + pages: 43, }, { isbn: "9781449337711", title: "Designing Evolvable Web APIs with ASP.NET", author: "Glenn Block, et al.", published: "2014-04-07T00:00:00.000Z", + pages: 55, } -] \ No newline at end of file +] + +function exibirDados (event){ + event.preventDefault(); + + let author = document.getElementById("nomeDoAutor").value; + let title = document.getElementById("tituloDoLivro").value; + let isbn = document.getElementById("isbnDoLivro").value; + let published = new Date(document.getElementById("dataDaPublicacao").value); + let pages = document.getElementById("numeroDePaginas").value; + let parseDataPublicacao = dataPublicacao.setDate(dataPublicacao.getDate() +1); + console.log(dataPublicacao, parseDataPublicaacao); + + if (author === "" || title === "" || isbn === "" || published === "") { + alert("Preencha as informações obrigatórias faltantes") } + else{ + books.push({ + author: autor, + titulo: titulo, + isbn: isbn, + published: dataDaPublicacao, + pages: paginas + }); + +function addBooks() { + + const resultList = document.getElementById("resposta"); + + books.forEach((book) => { + const parseDate = new Date(book.published); + const getData = parseDate.toLocaleDateString("pt-br"); + + resultList.innerHTML += ` + + + + ` + + + }) + + + +} +addBooks(); diff --git "a/Exerc\303\255cio de Casa/script/script2.js" "b/Exerc\303\255cio de Casa/script/script2.js" new file mode 100644 index 0000000..82639d6 --- /dev/null +++ "b/Exerc\303\255cio de Casa/script/script2.js" @@ -0,0 +1,46 @@ +function exibirDados (event){ + event.preventDefault(); + + let autor = document.getElementById("nomeDoAutor").value; + let titulo = document.getElementById("tituloDoLivro").value; + let isbn = document.getElementById("isbnDoLivro").value; + let dataPublicacao = document.getElementById("dataDaPublicacao").value; + let paginas = document.getElementById("numeroDePaginas").value; + let dataInsercao = new Date().toLocaleDateString("pt-br"); + let horarioInsercao = new Date().toLocaleTimeString("pt-br"); + + if (autor === "" || titulo === "" || isbn === "" || dataPublicacao === "") { + alert("Preencha as informações obrigatórias faltantes") } + else{ + + document.getElementById("resposta").innerHTML += ` + + + ${autor} + ${titulo} + ${isbn} + ${dataPublicacao} + ${paginas} + ${dataInsercao},${horarioInsercao} + + + ` + limparDados(); +} +function limparDados() { + document.getElementById("nomeDoAutor").value = ""; + document.getElementById("tituloDoLivro").value = ""; + document.getElementById("isbnDoLivro").value = ""; + document.getElementById("dataDaPublicacao").value = ""; + document.getElementById("numeroDePaginas").value = ""; + +} + +document.getElementById('resposta').addEventListener('click', function(event) { + if (event.target.className === "delete") { + let botao = event.target.parentElement; + botao.parentElement.remove(); + } +}) + +} diff --git "a/Exerc\303\255cio de Casa/style/style.css" "b/Exerc\303\255cio de Casa/style/style.css" index e69de29..be0c09b 100644 --- "a/Exerc\303\255cio de Casa/style/style.css" +++ "b/Exerc\303\255cio de Casa/style/style.css" @@ -0,0 +1,37 @@ +body { + background-color: grey; +} + +h1{ + text-align: center; +} + +input { + width: 100%; + } + +label{ + font-weight: bold; +} + +#botaoAdicionarLivro{ + background-color: rgb(77, 164, 235); + width: 100%; + color: white; +} + + +@media screen and (min-width:1024px){ + h1{ + text-align: center; + } + + input{ + width: 100%; + } + + th{ + padding: 40px; + } + +} \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..958c662 --- /dev/null +++ b/script.js @@ -0,0 +1,4 @@ +const numbers = [1, 2, 3, 4, 60, 80, -2]; + +console.log(numbers.length); +