Function ensurePrefix

Add prefix to string if it doesn't already have it

ensurePrefix("1234bbcc", "0x") -> "0x1234bbcc"
ensurePrefix("0x1234bbcc", "0x") -> "0x1234bbcc"
  • Parameters

    • string: string

      string to add prefix to

    • prefix: string

      prefix to add

    Returns string