As far as proper design for the increase of the counter?

Hello. On the page there are checkboxes, when you click on the current checkbox changes the value in the box below. Colleagues how correct the algorithm and its implementation...
let skills = document.querySelectorAll('label[name="js"]');
let counter = document.querySelector('.worksheet-result__counter-num');
let stepSkill = 25;

skills.forEach(function (element) {
 element.onclick = function () {
 if (this.previousElementSibling.value == 'no') {
 let counterVal = parseFloat(counter.value);
 this.previousElementSibling.value = 'yes';
 let skill = counterVal + stepSkill;
 counter.value = skill;
 } else {
 let counterVal = parseFloat(counter.value);
 this.previousElementSibling.value = 'no';
 let skill = counterVal - stepSkill;
 counter.value = skill;
}
}
})
June 8th 19 at 17:25
0 answer

Find more questions by tags JavaScript