// Reto
let numbers = [-9, 34 , -23, -2127 ,46, -6]
let numbersStrings = numbers.map{ (number) -> String in
var number = number
var output = ""
let minus = "menos"
let negative = number
number = number < 0 ? number * -1 : number
repeat{
output = digitNames[number%10]! + output
number /= 10
}while number > 0
output = negative < 0 ? minus + output : output
return output
}
print(numbersStrings)
[“menosNueve”, “TresCuatro”, “menosDosTres”, “menosDosUnoDosSiete”, “CuatroSeis”, “menosSeis”]
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?