0
I have the following question:
A programming teacher, tired of students arriving late, decided to cancel class if there are few gifts.
It represents the entrance of students as a array
of arrival times late, in minutes.
For example, if a student arrived 10 minutes late, another 5 minutes before the hour, another with 3 minutes late, and another punctual, may thus represent:
var alunosDaSegunda = [10, -5, 3, 0];
With this information and the minimum number of students to succeed the course, the teacher wants to know if the class will take place.
For example, assuming that the minimum number of students for the class to take place is 2 students, then the course of Monday will take place, because there was a student who was punctual and a student who arrived early.
acontece(alunosDaSegunda, 2) // true
But if the minimum quantity was 3, the class would not happen:
acontece(alunosDaSegunda, 3) // false
Write the following functions:
acontece
, which says whether the class will succeed according to thearray
of the students who entered.aberturas
, using aarray
with the arrays of students who entered the other days, and the minimum amount of students, and tell which days the classes took place and which.For example:
aberturas([alunosDaSegunda, alunosDaTerça, alunosDaQuarta], 2) // [true, false, false]
Added as reply - 14/05/2019 at 22:49
Guys, I can’t find the solution.
function acontece(estudantes) {
var quantidade = estudantes.length;
var positivos = 0;
for (var i = 0; i < quantidade; i++) {
if (estudantes[i] <= 0) {
positivos = positivos + 1;
}
}
}
How can I get it right ?
Welcome to Stackoverflow in English. I edited your question to remove the greetings as we usually keep the text as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the [chat]. If you have questions about the operation, rules and procedures of the site visit the [meta] :)
– Sorack
Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).
– Sorack