Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a constant named name with value "Alice".
iOS Swift
let [1] = "Alice"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
var instead of let for a constant.Capitalizing variable names incorrectly.
✗ Incorrect
Use
let to declare a constant and name as the variable name.2fill in blank
mediumComplete the code to declare a variable age with initial value 30.
iOS Swift
var [1] = 30
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
let instead of var for a variable.Capitalizing variable names incorrectly.
✗ Incorrect
Use
var to declare a variable and age as the variable name.3fill in blank
hardFix the error in the code by choosing the correct keyword to declare a variable that can change.
iOS Swift
[1] score = 100 score = 150
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
let for variables that need to change.Using JavaScript keywords like
const or final.✗ Incorrect
Use
var to declare a variable that can be changed later.4fill in blank
hardFill both blanks to declare a variable height of type Double with value 1.75.
iOS Swift
var [1]: [2] = 1.75
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
Int type for decimal numbers.Putting the type before the variable name.
✗ Incorrect
Use
height as the variable name and Double as the type for decimal numbers.5fill in blank
hardFill all three blanks to declare a constant greeting with inferred type and value "Hello".
iOS Swift
[1] [2] = [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
var instead of let for constants.Forgetting quotes around string values.
✗ Incorrect
Use
let for constant, greeting as name, and "Hello" as value with type inferred.