plamen1982

CSGO

Apr 1st, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. function csgo(args) {
  2. let n = Number(args[0])
  3. let budget = Number(args[1])
  4. let spendMoney = 0;
  5. let countItems = 0;
  6.  
  7. if(n > 7) {
  8. console.log('Sorry, you can\'t carry so many things!')
  9. } else {
  10. for(let i = 2; i < n + 2; i++) {
  11. switch(args[i]) {
  12. case 'ak47' :
  13. countItems++
  14. spendMoney += 2700
  15. break
  16. case 'awp' :
  17. countItems++
  18. spendMoney += 4750
  19. break
  20. case 'sg553' :
  21. countItems++
  22. spendMoney += 3500
  23. break
  24. case 'grenade' :
  25. countItems++
  26. spendMoney += 300
  27. break
  28. case 'flash' :
  29. countItems++
  30. spendMoney += 250
  31. break
  32. case 'glock' :
  33. countItems++
  34. spendMoney += 500
  35. break
  36. case 'bazooka' :
  37. countItems++
  38. spendMoney += 5600
  39. break
  40. }
  41. }
  42. let diff = budget - spendMoney
  43.  
  44. if(diff > 0) {
  45. console.log(`You bought all ${countItems} items! Get to work and defeat the bomb!`)
  46. } else {
  47. console.log(`Not enough money! You need ${Math.abs(diff)} more money.`)
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment