-
Notifications
You must be signed in to change notification settings - Fork 5
Exercicios Zé/Camila #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| function ehGolf(carro) { | ||
|
|
||
| return new Promise (function(resolve, reject){ | ||
| if(carro == 'golf'){ | ||
| resolve(true) | ||
| } else if(carro == undefined){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Porque esse teste de undefined? |
||
| reject("Não foi informada nenhum carro!") | ||
| }else{ | ||
| resolve(false) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| module.exports = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,27 @@ | ||
| function nome(pessoas) { | ||
|
|
||
| return pessoas.map((pessoas) => pessoas.nome); | ||
| } | ||
|
|
||
| function nomeComNota(pessoas) { | ||
|
|
||
| return pessoas.map((pessoas) => pessoas.nome + ' - ' + pessoas.nota); | ||
| } | ||
|
|
||
| function upperCase (pessoas) { | ||
|
|
||
| return pessoas.map((pessoas) => pessoas.toUpperCase(nome)); | ||
| } | ||
|
|
||
| function nomeComAprovacao (pessoas, notaParaAprovacao = 8) { | ||
|
|
||
| return pessoas.map((pessoas) => { | ||
| if(pessoas.nota > notaParaAprovacao){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. como faria com template string? |
||
| return pessoas.nome + ' - ' + 'Aprovado'; | ||
| } else { | ||
| return pessoas.nome + ' - ' + 'Reprovado' | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function alunos(pessoas) { | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. não precisa desse JSON.parse(JSON.stringify( |
||
| return pessoas.map((pessoas) => JSON.parse(JSON.stringify({ primeiroNome: pessoas.nome, notaFinal: pessoas.nota }))); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Porque esse uso de JSON aqui? |
||
|
|
||
| module.exports = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,45 @@ | ||
| function categoria(cursos, categoria) { | ||
|
|
||
| return cursos.filter((cursos) => { | ||
| if(cursos.categoria == categoria){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. == ou === ?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A função que passamos para o filter deve retornar um valor booleano (true ou false). Porque vocês retornaram cursos? |
||
| return cursos | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function duracaoMaiorQue(cursos, duracao) { | ||
|
|
||
| return cursos.filter((cursos) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cursos.filter((cursos) -> aqui vc pode dar qualquer nome, mas cursos, no plural, me parece não estar coeso
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Além disso é uma má prática fazer um shadow de variáveis. https://stackoverflow.com/questions/11901427/an-example-of-variable-shadowing-in-javascript |
||
| if(cursos.duracao > duracao){ | ||
| return cursos | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function duracaoMenorQue(cursos, duracao) { | ||
|
|
||
| return cursos.filter((cursos) => { | ||
| if(cursos.duracao < duracao){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A função que passamos para o filter deve retornar um valor booleano (true ou false). Porque vocês retornaram cursos? |
||
| return cursos | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function comProfessor(cursos) { | ||
|
|
||
| return cursos.filter((cursos) => { | ||
| if(cursos.professor){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A função que passamos para o filter deve retornar um valor booleano (true ou false). Porque vocês retornaram cursos? |
||
| return cursos | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function semProfessor(cursos) { | ||
|
|
||
| return cursos.filter((cursos) => { | ||
| if(!cursos.professor){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A função que passamos para o filter deve retornar um valor booleano (true ou false). Porque vocês retornaram cursos? |
||
| return cursos | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function descricao(cursos, regex) { | ||
|
|
||
| return cursos.filter((cursos) => cursos.descricao.match(regex)) | ||
| } | ||
|
|
||
| module.exports = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e se eu passar null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bateria de testes precisa ser melhorada...