what should correct below code?
<p> {ads.filter(obj => obj._id === this.state.selectedad_id) .map(obj =>obj.expiry_date && `you have complete task in${fromnow(moment(obj.expiry_date))}` )} </p> this working
<p> {ads.filter(obj => obj._id === this.state.selectedad_id) .map(obj => obj.expiry_date && fromnow(moment(obj.expiry_date)) )} </p> but how can concat you have complete task in when obj.expiry_date not null?
you can return ternary , use template literal string interpolation es6.
ads.filter(obj => obj._id === this.state.selectedad_id) .map(obj => obj.expiry_date ? `you have complete task in ${fromnow(moment(obj.expiry_date))}` : false)
Comments
Post a Comment