daily pastebin goal
72%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vendingMashine(input) {
  2.     let money = Number(input.shift());
  3.     let coins = money * 100;
  4.     let counter = 0 ;
  5.    
  6.  
  7.     while(coins > 0){
  8.         if (coins >= 200){
  9.         coins -= 200
  10.         counter++;
  11.         } else if (coins >= 100) {
  12.             coins -=100
  13.             counter++;
  14.         } else if (coins >=50){
  15.             coins -= 50
  16.             counter++;
  17.         } else if (coins >=20){
  18.             coins -= 20
  19.             counter++;
  20.         } else if (coins >=10){
  21.             coins -= 10
  22.             counter++;
  23.         } else if (coins >=5){
  24.             coins -= 5
  25.             counter++;
  26.         } else if (coins >=2){
  27.             coins -= 2
  28.             counter++;
  29.         } else if (coins >=1){
  30.             coins -= 1
  31.             counter++;
  32.         }
  33.        
  34.     }
  35.     console.log(counter)
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top