Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 562 Bytes

fixme_replace_all_dots.md

File metadata and controls

32 lines (25 loc) · 562 Bytes

Description

The code provided is supposed replace all the dots . in the specified String str with dashes -

But it's not working properly.

Task

Fix the bug so we can all go home early.

Notes

String str will never be null.

def replaceDots(str)
  str.sub(/./, '-')
end

My Solution

def replaceDots(str)
  str.gsub('.', '-')
end

Better/Alternative solution from Codewars

def replaceDots(str)
  str.tr('.', '-')
end