DEV Community

Discussion on: Daily Challenge #163 - Significant Figures

Collapse
 
savagepixie profile image
SavagePixie • Edited

I think this should do the trick, I'll test it later.

JavaScript

const significant = str => str.includes('.')
   ? str.replace(/^0+/, '').length - 1
   : str.replace(/^0+|0+$/g, '').length