I am using .replace() method to filter my data.
Like this :
this.state.date.toString().slice(13,15)
.replace('Jan', '01')
.replace('Feb', '02')
.replace('Mar', '03')
.replace('Apr', '04')
.replace('May', '05')
.replace('Jun', '06')
.replace('Jul', '07')
.replace('Aug', '08')
.replace('Sep', '09')
.replace('Oct', '10')
.replace('Nov', '11')
.replace('Dec', '12')
.replace(/\s/g, '')
The problem is that I need to apply this method in multiple places and I want to assign all the .replace() method as a variable.
edited
I want to assign .replace() as a variable like this
const filter = .replace('Jan', '01')
.replace('Feb', '02')
.replace('Mar', '03')
.replace('Apr', '04')
.replace('May', '05')
.replace('Jun', '06')
.replace('Jul', '07')
.replace('Aug', '08')
.replace('Sep', '09')
.replace('Oct', '10')
.replace('Nov', '11')
.replace('Dec', '12')
.replace(/\s/g, '')
So I could use it like this :
this.state.date.toString().slice(13,15).filter
this.state.date.getMonth() + 1