Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion concessionaria-util.js
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){

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?

Copy link
Owner

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...

Copy link
Owner

Choose a reason for hiding this comment

The 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 = {
Expand Down
16 changes: 11 additions & 5 deletions converte.lista.js
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){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

como faria com template string?
e com ternário?

return pessoas.nome + ' - ' + 'Aprovado';
} else {
return pessoas.nome + ' - ' + 'Reprovado'
}
})
}

function alunos(pessoas) {

Choose a reason for hiding this comment

The 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 })));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Porque esse uso de JSON aqui?


module.exports = {
Expand Down
32 changes: 26 additions & 6 deletions separa.lista.js
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){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== ou === ?

Copy link
Owner

Choose a reason for hiding this comment

The 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) => {

Choose a reason for hiding this comment

The 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

Copy link
Owner

Choose a reason for hiding this comment

The 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){
Copy link
Owner

Choose a reason for hiding this comment

The 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){
Copy link
Owner

Choose a reason for hiding this comment

The 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){
Copy link
Owner

Choose a reason for hiding this comment

The 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 = {
Expand Down