[JS Practice] Boiled Eggs

Title :

Multiplication table


You are the greatest chef on earth. No one boils eggs like you! Your restaurant is always full of guests, who love your boiled eggs. But when there is a greater order of boiled eggs, you need some time, because you have only one pot for your job. How much time do you need?

Your Task

Implement a function, which takes a non-negative integer, representing the number of eggs to boil. It must return the time in minutes (integer), which it takes to have all the eggs boiled.


  • you can put at most 8 eggs into the pot at once
  • it takes 5 minutes to boil an egg
  • we assume, that the water is boiling all the time (no time to heat up)
  • for simplicity we also don’t consider the time it takes to put eggs into the pot or get them out of it


cookingTime(0); // must return 0
cookingTime(5); // must return 5
cookingTime(10); // must return 10
cookingTime(16); // must return 10

My solution :

function cookingTime(eggs) {
 var boilTime = 5,
     maxBoilEggs = 8; 
 return Math.ceil(eggs/maxBoilEggs)*boilTime;

Most important key word for solution is the ceil function, which round a number upward to it’s nearest integer

Ref. from codewars

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s