My node version 12 does not recognize optional chaining operator. Sometimes the match is null
. It complains about
Unexpected token '.'
export function getDiscount(description) {
return description.match(/\d+(\%|\s\bpercent\b)/)?.[0];
}
Do I need to set an flag or something?
It works here
console.log(null?.[0])