@ParasArora/

halloween sale

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function howManyGames
(price, discount, minPrice, budget) {
  let count = 0;
  let cost = price;
  
  while(budget >= minPrice && budget - cost >= 0){
    console.log(budget, cost);
    budget = budget - cost;

    if(cost - discount > minPrice){
      cost = cost - discount;
    }else{
      cost = minPrice;
    }

    count++;
  }
  

  return count;

}


// howManyGames(20, 3, 6, 90); // 6
// howManyGames(100, 12, 55, 95)
howManyGames(100, 19, 1, 180);
node v10.16.0