param { string } str param { number } precision returns { string } example export const trimStringDecimals = ( str , precision ) => { if ( ! str || ! str . includes ( "." ) ) { return str ; } const [ integer , decimals ] = str . split ( "." ) ; if ( decimals . length <= precision ) { return str ; } return `${ integer }.${ decimals . slice ( 0 , precision ) }` ; } ;