Browse Source

HW01 done

Volddemar4ik 2 years ago
parent
commit
52a6119b8b
1 changed files with 4 additions and 4 deletions
  1. 4 4
      js/01/HW1.js

+ 4 - 4
js/01/HW1.js

@@ -6,18 +6,18 @@ const lightNightRate = +prompt('Введите стоимость кВт/час
 
 const daysInMonth = +prompt('Кол-во дней в месяце:', 'дней')
 
-const priceDay = lightDayUse * lightDayRate
+const priceDay = +((lightDayUse * lightDayRate).toFixed(2))
 const priceDayAlert = 'Стоимость потребленной электроэнергии в дневное время: ' + priceDay + ' грн.'
 alert(priceDayAlert);
 
-const priceNight = lightNightUse * lightNightRate
+const priceNight = +((lightNightUse * lightNightRate).toFixed(2))
 const priceNightAlert = 'Стоимость потребленной электроэнергии в ночное время: ' + priceNight + ' грн.'
 alert(priceNightAlert);
 
-priceMonth = priceDay + priceNight
+priceMonth = (priceDay + priceNight).toFixed(2)
 const priceMonthAlert = 'Стоимость потребленной электроэнергии в месяц: ' + priceMonth + ' грн.'
 alert(priceMonthAlert);
 
-const usePerDay = (lightDayUse + lightNightUse) / daysInMonth
+const usePerDay = ((lightDayUse + lightNightUse) / daysInMonth).toFixed(2)
 const usePerDayAlert = 'Среднее потребление в день: ' + usePerDay + '  кВт/ч.'
 alert(usePerDayAlert);