+ 3
Logical and Boolean operators 3 (Volunteer Teams)
Hello! I have figured out test 1 and test 2 by coding function main() { var numberVolunteers = parseInt(readLine(), 10) // Your code here var x = 5 - (numberVolunteers % 5); console.log(x); } But can’t for the life of me to output 0 for test 3 at the same time. Can anyone please help me with this?
9 ответов
+ 3
The response about if else has not been taught to this point you should be able to do with what has been learned to this point in basic concepts
+ 2
question asks how many more volunteers would you need if you were to distribute all the available ones equally in 5 groups ,so according to your solution even if the numberVolunteers % 5 equals to 0 means they are distributed equally you still need 5 more volunteers !
what you need to do is use an if else statement so if the output is 0 you don't do 5-remainder
+ 2
thank you!!
+ 1
I did an if else statement.
Works fine to me, but I think there's a better way to do it.
+ 1
Hope this can help. It approves all the test :))
function main() {
var numberVolunteers = parseInt(readLine(), 10)
// Your code here
let remainder = (numberVolunteers %5);
if(remainder !=0){
let ans = (5 - remainder )
console.log(ans)
}else{
console.log(0)
}
}
0
i could use some help on it
0
I’m actuallu still having issues with this problem. If I solve it, I’ll let you know
0
i figured it out Nick!
0
awesome! what was your process of figuring it out?