DEV Community

loading...

Discussion on: Daily Challenge #9 - What's Your Number?

Collapse
neotamizhan profile image
Siddharth Venkatesan

Ruby

def phone_number(nums)
  puts "(#{nums[0..2].join("")}) #{nums[3..5].join("")}-#{nums[6..-1].join("")}"
end

puts phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) #(123) 456-7890