Day 1 of JavaScriptmas - Candies Solution
Sekti Wicaksono
Posted on December 15, 2020
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;
}
💖 💪 🙅 🚩
Sekti Wicaksono
Posted on December 15, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.