Kotlinlearncs.online LogoJava
Return to List

Homework: Reformat a Phone Number

Created By: Geoffrey Challen
/ Version: 2020.9.0

Write a function called reformatPhoneNumber. It should take a String containing a phone number in the format 111-222-3333 and return it reformatted as (111) 222-3333.

You will want to explore the various String methods to help you with this task. In particular, you may find split and substring helpful. There are solutions that use split, others that use substring, and probably others that use neither!

Related Lessons

Stuck? You may find these lessons helpful: