fork download
  1. var little = { name: "Маленький", price: 50 , calories: 20 };
  2. var big = { name: "Большой", price: 100 , calories: 40 };
  3.  
  4. var cheese = { name: "Сыр", price: 10 , calories: 20 };
  5. var salad = { name: "Салат", price: 20 , calories: 5 };
  6. var potato = { name: "Картофель", price: 15 , calories: 10 };
  7.  
  8. var sause = { name: "Приправа", price: 15 , calories: 0 };
  9. var mayo = { name: "Майонез", price: 20 , calories: 5 };
  10.  
  11.  
  12.  
  13.  
  14. function calculation(sort, stuffing, sause, mayo) {
  15. var price = 0;
  16. var calories = 0;
  17. var arr = [];
  18.  
  19. switch (sort) {
  20. case little:
  21. price += 50;
  22. calories += 20;
  23. break
  24. case big:
  25. price += 100;
  26. calories += 40;
  27. break
  28. default:
  29. arr.push("Ошибка с выбором размера гамбургера");
  30. return arr;
  31. }
  32.  
  33. switch (stuffing) {
  34. case cheese:
  35. price += 10;
  36. calories += 20;
  37. break
  38. case salad:
  39. price += 20;
  40. calories += 5;
  41. break
  42. case potato:
  43. price += 15;
  44. calories += 10;
  45. break
  46. default:
  47. arr.push('Ошибка с выбором начинки гамбургера');
  48. return arr;
  49. }
  50.  
  51. if (sause) { //к примеру через промпт спросить, ответ true или false
  52. price += 15;
  53. calories += 0;
  54. };
  55.  
  56. if (mayo) {
  57. price += 20;
  58. calories += 5;
  59. };
  60.  
  61. arr.push(price);
  62. arr.push(calories);
  63. return arr;
  64. }
  65.  
  66.  
  67. console.log(calculation(big, salad, true, true));
Runtime error #stdin #stdout #stderr 0.44s 321920KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: uncaught JavaScript runtime exception: ReferenceError: "console" is not defined.