Skip to content Skip to sidebar Skip to footer

How Can I Another Filter For Score Which Will Show The Results Matching The Range?

I wanted to add another filter for score with the options as Very High, High, Medium and Low. If the score is <20 then low, 21-50 then medium, 51-70 then high and >71 then ve

Solution 1:

Add one more else if to your code:

elseif (key === "score") {
      const low = filters[key] === "20" && user["score"] <= filters[key];
      const medium =
        filters[key] === "50" && user["score"] < 50 && user["score"] >= 21;
      const high =
        filters[key] === "70" && user["score"] < 70 && user["score"] >= 51;
      const veryHigh = filters[key] === "71" && user["score"] >= 71;
      if (low || medium || high || veryHigh) {
        return user;
      }
    } 

Also, send values from HTML:

<optionvalue="71">Very High</option><optionvalue="70">High</option><optionvalue="50">Medium</option><optionvalue="20">Low</option>

https://angular-ivy-xtgnv5.stackblitz.io Also, please mark as right, if your problems gets solved.

Post a Comment for "How Can I Another Filter For Score Which Will Show The Results Matching The Range?"