I have a function which returns an array which has filter, sort and map. How can I push a new item into the array before its sorted?
When I try the following I get an error saying push isnt a function.
return (
myArray
.filter((item) => {
return item.value > 2;
})
.push(newThiny) // This doesn't work
.sort((a, b) => {
if (a.name < b.name)
return -1;
if (a.name > b.name)
return 1;
return 0;
})
.map((item) => {
return (
<ChooseAnExercises
key={item.name}
name={item.name}
active={item.active}
setNumber={this.props.number}
updateValue={this.props.updateValue}
/>
)
})
)