0👍
✅
The code you’ve posted will always loop through all entries in testArray
and take some action for each entry. I think the behavior you want is for the code to only take action on an entry that matches, and default if no entry matches. There are many ways to achieve that behavior but one way is the following
date(newValue) {
const matched = testArray.find(entry => entry.date === newValue);
if (matched) {
this.disabledHours = matched.times;
} else {
this.defaultHours();
}
}
Source:stackexchange.com