settingsAccountsettings
Menusettings

Q: Boxes and Bottles (JavaScript Task)

+2 votes

Write a JS function to calculate how many boxes will be needed to fit n bottles if each box fits k bottles.

The input comes as two number arguments:

  • The first element is the number of bottles
  • The second is the capacity of a single box.

The output should be printed to the console.

Examples:
Input:
20
5
Output:
4


Input:
15
7
Output:
3


Input:
5
10
Output:
1

asked in JavaScript category by user hues

1 Answer

+1 vote

Here's my code:

function bottleBoxes(a, b) {
    let boxesNeeded = Math.ceil(Number(a) / Number(b));
    console.log(boxesNeeded);
}

bottleBoxes(5, 10);

Cheers!

boxes with bottles

answered by user icabe
...