Seeking assistance on sorting a multi-dimensional array returned from an API to enable users to choose a range based on beats.
I'm currently facing challenges with the data my API is returning.
var myObj = [{
title: 'title one',
beats: 1
}, {
title: 'title two',
beats: 2
}, {
title: 'title three',
beats: 3
}, {
title: 'title four',
beats: 4
}, {
title: 'title five',
beats: 5
}, {
title: 'title six',
beats: 6
}, {
title: 'title seven',
beats: 7
}, {
title: 'title eight',
beats: 8
}, {
title: 'title nine',
beats: 9
}, {
title: 'title ten',
beats: 10
}];
Currently, I am attempting to allow users to select a range based on beats.
For example, if they select 1-4, the expected output would be:
var myObj = [{
title: 'title one',
beats: 1
}, {
title: 'title two',
beats: 2
}, {
title: 'title three',
beats: 3
}];
Similarly, selecting 8-10 should return:
var myObj = [{
title: 'title eight',
beats: 8
}, {
title: 'title nine',
beats: 9
}, {
title: 'title ten',
beats: 10
}];
Any suggestions on what function I could use for this purpose will be highly appreciated. Thanks in advance!