*Solved* Pomodoro JS Question on buttons:

*Solved* Pomodoro JS Question on buttons:
0

#1
//plus / minus buttons
$("#minusA").click(function () {
    $("#minuteA").val(function () {
        return this.value - 1;
    });
});
$("#plusA").click(function () {
    $("#minuteA").val(function () {
        return this.value + 1;
    });
});
$("#minusB").click(function () {
    $("#minuteB").val(function () {
        return this.value - 1;
    });
});
$("#plusB").click(function () {
    $("#minuteB").val(function () {
        return this.value + 1;
    });
});

This is the code for the buttons I have so far. Can someone tell my why this code works for the - buttons but does not for the +?

Hitting - cause the value to go from 25 to 24. Hitting + causes the value to go from 25 to 251.


#2

I think it’s because this.value here is a string, so you get the string '251'. Try using Number(this.value) or +this.value to coerce it to a number.


#3

Thank you for the help. I found out why it does that for + and not -.