Skip to content

Instantly share code, notes, and snippets.

@YKalashnikov
Last active April 5, 2017 00:07
Show Gist options
  • Save YKalashnikov/fd299571fee403b6990d9c1fe18bd2ff to your computer and use it in GitHub Desktop.
Save YKalashnikov/fd299571fee403b6990d9c1fe18bd2ff to your computer and use it in GitHub Desktop.
# Write a method that converts an array of ten integers into a phone number in the format "(123) 456-7890".
WHAT'S WRONG WITH THE CODE?
# Write a method that converts an array of ten integers into a phone number in the format "(123) 456-7890".
def to_phone_number(arr)
chunk_one = arr[0..2].join
chunk_two = arr[3..5].join
chunk_three = arr[6..9].join
"(" + chunk_one + ")" + " " + chunk_two + "-" + chunk_three
end
puts (to_phone_number("1234567890"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment