0
Help with Javascript Tests
Ive been stuck with alot of the JavaScript tests, mainly due to the fact that its asking me to create a math solution that will make ALL of the results correct with a single solution. https://sololearn.com/coach/420/?ref=app Ive been stuck on this for im not even sure how long but its been longer then a week at this point. Any help would be greatly appreciated
9 Réponses
+ 1
Volunteers have been divided into 5 groups with equal number of members. If any group has fewer than 5 people, more volunteers must be recruited to fill the empty spots.
Write a program that takes the number of volunteers and outputs to the console how many volunteers need to be hired to have 5 equal groups.
Sample Input
24
Sample Output
1
Explanation
The nearest number to 24 that is multiple of 5 is 25, so we need 1 more volunteer (24+1=25) to get 5 equal groups
+ 1
The input is supposed to affect 5 different questions, with just one console.log, and thats what confuses me- i can easily do the math, but i don’t know how i can make them all work with just one solution
+ 1
I did but it doesnt work. What i mean is- No number for the modulus will make all sample inputs turn into the expected output
0
didnt work either, although im sure its because that code is already there.
0
function main() {
var numberVolunteers = parseInt(readLine(), 10)
// Your code here
console.log(numberVolunteers % 5)
}
0
Bles T Let's use that logic you have above in the console log with the numbers in the example. The example says if the number of volunteers is 24, the answer we're looking for is 1. That's because the remainder when doing 24 % 5 is 4, so we need 1 extra person to get that last group to have 5 people.
Your logic above is just console logging 24 % 5. The numberOfVolunteers % 5 is a good start but that's not what you need to output. You're missing the final step. I hope that helps.