Im looking to find a way to reduce/filter an array based on a value. So for example:
I have an array: _postInsightSizeOptions: number[] = [5, 10, 25, 50, 100];
For Example:
Input = 6 - the new array (_postInsightSizeOptionsFiltered) should only output [5, 10]
Input = 5 - the new array (_postInsightSizeOptionsFiltered) should only output [5]
Input = 28 - the new array (_postInsightSizeOptionsFiltered) should only output [5, 10, 25, 50]
My Attempt: this._postInsightSizeOptionsFiltered = this._postInsightSizeOptions.filter(size => size <= 7); but this only outputs [5] instead of [5, 10]
10is not<= 7. Why do you expect10to be in the output?6produce[5, 10]but5doesn't? Why does28also produce50?