1

I've got this array.

const array = [0, 5.476, 11.251, 31.916, 44.007, 53.911, 58.628, 65.729, 75.222, 88.849, 100]

How would I go about only returning values between 23.419 and 46.839 without calling by index. I wouldn't be surprised if there's a native function for this, as to why my question is short. Thanks.

1
  • 1
    you can use filter function Commented May 29, 2020 at 13:29

1 Answer 1

1

Simply use filter function :

array.filter(item => item >= 23.419 && item <= 46.839);
Sign up to request clarification or add additional context in comments.

3 Comments

Interesting, had a brief look at filters, what exactly do they perform? This is great btw.
you can check the documentation it is well explained : developer.mozilla.org/fr/docs/Web/JavaScript/Reference/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.