1
EXERCISE: Set the function possibleIrAoBanco, take two parameters, the first is diaDaSemana (string) and the second horaAtual(number), the function must return true, only if the database is open. Remember that you can do what is needed using Return without making use of if/Else.
I MADE THE FOLLOWING CODE:
function possoIrAoBanco( diaDaSemana, horaAtual){
var horaFuncionamentoBanco = (9, 10,11,12,13,14,15);
var diasFuncionamentoBanco = ('segunda-feira', 'terça-feira', 'quarta-feira','quinta-feira', 'sexta-feira');
return horaAtual === horaFuncionamentoBanco &&diaDaSemana=== diasFuncionamentoBanco;
}
HOWEVER: Before was appearing the error of the solution to go against string, but I used the tip of colleague Sergio in another issue that I had doubt and thought it would solve. But now when I put the following test on the console can be FALSE('Friday', 10) it returns FALSE even if the date is Friday and the time is 10. Would anyone know what’s causing this mistake?
Function possoIrAoBranco(diaDaSemana, horaAtual) { var diasFechados = ('Saturday', 'Sunday'); Return diaDaSemana !== diasFechados && horaAtual >= 9 && horaAtual <= 15; } I believe this test is from Digital House. If so, see that he will not accept the code with var diasFechados = ('Saturday', 'Sunday'); but only with ('Saturday, 'Sunday''). I don’t know if this was something anticipated, but every other working day is accepted in lowercase letters but the weekend is not. I believe it’s a mistake, but it left me for a long time thinking that the logic of function was wrong.
– Karina Sonaglio
Function possoIrAoBanco(dayDaSemana, timeAtual){ Return timeAtual >= 9 && timeAtual <= 15 && dayDaSemana != " Saturday" && dayDaSemana != " Sunday" } Mine was like this and I managed to pass... the problem is the accent of Saturday and Sunday with bad letter.
– karoliny de castro