DEV Community

Discussion on: Daily Challenge #276 - Unwanted Dollar Signs

Collapse
 
rafi993 profile image
Rafi

Ruby

def money_value(money)
  money_str = money.tr("$", "").tr(" ", "")
  # This is to remove trailing zeros
  if money_str.to_f == money_str.to_i
    return money_str.to_i
  end
  return money_str.to_f
end