Why replace function return index of even numbers?

Viewed 25

I'm trying to replace underscore _ by its number of occurrence?

'_,_,_,_'.replace(/_/g,(x,i)=>i)
'0,2,4,6'

expected output: '0,1,2,3'

0 Answers
Related