I'm facing an issue where a value of 0 is being added to the newArray as an Object, which I don't want. How can I resolve this?
modus = {start: -1, end: 0}
Output newArray:
0: {value: -1, label: -1} 1: {value: 0, label: 0}
I need the Output newArray to exclude {value: 0, label: 0}
const getOptions = (modus) => {
console.log(modus.range.end + ' ' + modus.range.start)
let data;
if (modus.range.end < 0.00 ) {
data = Array(modus.range.start - modus.range.end + 1).fill('').map((_, idx) => modus.range.end + idx)
} else {
data = Array(modus.range.end - modus.range.start + 1).fill('').map((_, idx) => modus.range.start + idx)
}
const newArray = data.map(item => ({ value: item, label: item }));
return newArray
}