kremalicious/blog

View on GitHub
src/features/Web3/lib/normalizeAmount/normalizeAmount.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
export function normalizeAmount(amount: string): string {
  // Replace comma used as a decimal separator with a period
  let newAmount = amount.replace(',', '.')

  // Remove any non-digit or non-decimal characters
  newAmount = newAmount.replace(/[^\d.]/g, '')

  return newAmount
}