packageutilsimport("errors""fmt""strconv")funcFormatPhoneNumber(phoneNumberArray[]int)(string,error){iflen(phoneNumberArray)!=10{return"",errors.New("Array length must be 10")}returnfmt.Sprintf("(%s) %s-%s",intArrayToString(phoneNumberArray[:3]),intArrayToString(phoneNumberArray[3:6]),intArrayToString(phoneNumberArray[6:])),nil}funcintArrayToString(intArray[]int)string{number:=""for_,num:=rangeintArray{number+=strconv.Itoa(num)}returnnumber}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Daily Challenge #9 - What's Your Number?
For further actions, you may consider blocking this person and/or reporting abuse