JS calc - regex assistance

Tell us what’s happening:
Probably i am not understanding the exact requirement. but below code does not seem to satisfy the “0” prefix criteria.

Your code so far


this.setState({strDisplay:this.state.strDisplay.replace(/^0{2,}/, “”)+event.target.innerHTML.replace(/^0{2,}/, “”)})


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36

Challenge: Build a JavaScript Calculator

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.