includes
returns a flag indicating whether the specified value exists in your array:
Array.prototype.includes() - JavaScript | MDN[
^]
In this case, you are combining two strings with the
&&
operator. That's not a sensible operation - in my browser, it seems to consistently return the second string, but other browsers might behave differently.
Use
parseInt
to convert the value to a number:
parseInt() - JavaScript | MDN[
^]
Then use
filter
to filter your array to just the values between those two numbers:
Array.prototype.filter() - JavaScript | MDN[
^]
Then do something with that filtered array.
const startValue = parseInt(from1.value);
const endValue = parseInt(to1.value);
const matchingValues = sourceArray.filter(i => startValue <= i && i <= endValue);
console.log("Match:", matchingValues);