So I have this problem where I am populating a range input using data coming from an external json file...
So basically the data has a bunch of objects with an array of values and text in each object. But some of the objects don't have consecutive values to loop though and output on the range slider like this:
var someObj = [
{
value: 1,
text: 'A'
},
{
value: 2,
text: 'B'
},
{
value: 3,
text: 'C'
},
{
vaule: 5,
text: 'D'
},
{
value: 6,
text: 'E'
},
{
vaule: 8,
text: 'F'
}
];
Notice that Value: 4 and value: 7 are missing, this can change too, in some objects value: 11 and value: 13 are missing too for example.
So basically what i need to achieve is to loop through each object and if there are values missing to add the value in and duplicate the text value from the value before so for example...
var someObj = [
{
value: 1,
text: 'A'
},
{
value: 2,
text: 'B'
},
{
value: 3,
text: 'C'
},
{
vaule: 5,
text: 'D'
},
{
value: 6,
text: 'E'
},
{
vaule: 8,
text: 'F'
}
];
Would become
var someObj = [
{
value: 1,
text: 'A'
},
{
value: 2,
text: 'B'
},
{
value: 3,
text: 'C'
},
{
value: 4,
text: 'C'
},
{
vaule: 5,
text: 'D'
},
{
value: 6,
text: 'E'
},
{
vaule: 7,
text: 'E'
},
{
vaule: 8,
text: 'F'
}
];
Is this possible and if so how on earth would i go about it please??
thanks in advance
refer this one :https://jsfiddle.net/cw5kkpgu/