Help me please. How to make the checkbox values add to the Total Cost of my calculator? thank
$(document).ready(function(n) { var l = "item-1"; function e(t) { var c = 0, a = { "item-1": [{ begin: 1, price: 600 }, { begin: 3, price: 600 }, { begin: 6, price: 600 }, { begin: 11, price: 600 }, { begin: 30, price: 500 }, { begin: 51, price: 500 } ] }; var f = 0; function test(item) { if (item.checked) { f += parseInt(item.value); } else { f -= parseInt(item.value); } } a[l].forEach(function(e, i) { a[l][i].begin <= t && (c = a[l][i].price, n(".calc-total-price").text(t * c + f), n(".calc-price").text(c)) }) } n(".item-type").click(function() { n(".item-type").removeClass("item-type-active"), n(this).addClass("item-type-active"), l = n(this).data("id"), n(".calc-count").text(n(".calc-range").val()), e(n(".calc-range").val()) }), n(".calc-range").on("input", function() { n(".calc-count").text(this.value), e(this.value) }) })
<!DOCTYPE html> <html lang="ru"> <body> <!--БЛОК 1 <--> <div class="tsk"> <div class="ask-blocks wow fadeInLeft" data-wow-duration="2s"> <div class="item item1"> <h4 class="item-type item-type-active knoop" data-id="item-1">Калькулятор цен</h4> <div> <input class="checkbox" type="checkbox" value="900" onClick="test(this);"/> Фотосессия: 900 ₽<br /> <input class="checkbox" type="checkbox" value="150" onClick="test(this);"/> Чистка ушей: 150 ₽ <br /> <input class="checkbox" type="checkbox" value="300" onClick="test(this);"/> Стрижка ногтей: 300 ₽ <br /> <input class="calc-range m-top-20 sliderock" type="range" min="1" max="60" step="1" value="1"> <br> <div style="text-align: left;"> Количество дней: <p class="calc-count" style="display: inline;">1</p> <br>Общая стоимость: <span class="calc-total-price" style="display: inline;"></span> рублей <br> Цена за сутки: <span class="calc-price" style="display: inline;"></span> рублей </div> </div> </div> </div> </div> <!--БЛОК 1 КОНЕЦ--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </body> </html>