+ 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?

18th Dec 2020, 2:14 PM
Nick Carothers
9 Respostas
+ 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
11th Sep 2021, 11:02 PM
Shannon McLarey
+ 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
18th Dec 2020, 2:27 PM
Abhay
Abhay - avatar
+ 2
thank you!!
18th Dec 2020, 2:45 PM
Nick Carothers
+ 1
I did an if else statement. Works fine to me, but I think there's a better way to do it.
23rd Jan 2021, 11:05 PM
Philipp Minich
Philipp Minich - avatar
+ 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) } }
17th Aug 2021, 5:58 AM
riven 2018
riven 2018 - avatar
0
i could use some help on it
8th Jan 2021, 3:27 PM
Darryl T. Davis
0
I’m actuallu still having issues with this problem. If I solve it, I’ll let you know
9th Jan 2021, 3:27 PM
Nick Carothers
0
i figured it out Nick!
9th Jan 2021, 5:42 PM
Darryl T. Davis
0
awesome! what was your process of figuring it out?
9th Jan 2021, 8:17 PM
Nick Carothers