Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an enum named Direction.
Swift
enum [1] {
case north
case south
case east
case west
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for enum name
Using plural form which is not the given enum name
✗ Incorrect
The enum name should be Direction with a capital D as per Swift naming conventions.
2fill in blank
mediumComplete the code to add a case named 'up' to the enum.
Swift
enum Movement {
case [1]
case down
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters for case names
Choosing a wrong direction name
✗ Incorrect
The case to add is up as specified.
3fill in blank
hardFix the error in the enum case declaration.
Swift
enum Color {
case [1]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters for enum cases
Using mixed case which is not standard
✗ Incorrect
Enum cases in Swift should be lowercase, so red is correct.
4fill in blank
hardFill both blanks to declare an enum with two cases: 'spring' and 'fall'.
Swift
enum Season {
case [1]
case [2]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong season names
Using uppercase letters
✗ Incorrect
The enum Season has cases spring and fall as requested.
5fill in blank
hardFill all three blanks to declare an enum with cases 'small', 'medium', and 'large'.
Swift
enum Size {
case [1]
case [2]
case [3]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including a case not requested like 'extraLarge'
Using uppercase letters
✗ Incorrect
The enum Size includes the cases small, medium, and large as required.