The 1st challenge is to count how many candies of each child gonna be get if someone has X candies.
for instance, if granpa have 10 candies and there are 3 grandchildren.
How many each child going to be get candy?
So 10/3 is 3.33. In general, each child has 3 candies.
Total candies for children will be 3*3 is 9.
So there is JavaScript the solution
function candies(children, candy) {
let eaten = Math.floor(candy/children);
return children * eaten;
}
Top comments (0)