Skip to content

Instantly share code, notes, and snippets.

@shakyra
Created May 21, 2019 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shakyra/8507c01e12e3f8531353e7fa7da59f94 to your computer and use it in GitHub Desktop.
Save shakyra/8507c01e12e3f8531353e7fa7da59f94 to your computer and use it in GitHub Desktop.
When provided with a number between 0-9, return it in words. Input :: 1 Output :: "One". Try using "Switch" statements.
func switchItUp (_ number: Int) -> String {
switch number {
case 0:
return "Zero"
case 1:
return "One"
case 2:
return "Two"
case 3:
return "Three"
case 4:
return "Four"
case 5:
return "Five"
case 6:
return "Six"
case 7:
return "Seven"
case 8:
return "Eight"
case 9:
return "Nine"
default:
return "None"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment