+ 1
Why this slider console is not working as it is supposed to
Set the value of slider to its minimum in one click and watch the console Why like that? https://code.sololearn.com/Wlc6bYnMHHgJ/?ref=app
1 Answer
+ 1
let prevValue = slider.value;
The type of slider.value is string instead of number. So you have to change type to number. You can convert strings to numbers using a unary plus operator as opposed to parseInt() or Number()
let prevValue = parseInt(slider.value);
let prevValue = Number(slider.value);
let prevValue = +slider.value;