JSFiddle - React, Tailwind, and code Playground JavaScript var num = 134.342; num = num.toString().match(/^(\d*(\.\d{0,2})?)/)[0]; alert(num);