Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a save slot variable.
Unity
int [1] = 1;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague or unrelated variable names.
Using reserved keywords.
✗ Incorrect
The variable slotNumber is a clear and common name for a save slot identifier.
2fill in blank
mediumComplete the code to save player data to a slot using PlayerPrefs.
Unity
PlayerPrefs.SetString("SaveSlot" + [1], playerData);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable that is not defined.
Forgetting to convert the slot number to string.
✗ Incorrect
Using slotNumber in the key string helps identify which save slot is being saved.
3fill in blank
hardFix the error in the code to load data from a save slot.
Unity
string data = PlayerPrefs.GetString("SaveSlot" + [1], "");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong variable name causing key mismatch.
Forgetting to provide a default value.
✗ Incorrect
The variable slotNumber correctly identifies the save slot to load.
4fill in blank
hardFill both blanks to check if a save slot exists and load it.
Unity
if (PlayerPrefs.HasKey("SaveSlot" + [1])) { string data = PlayerPrefs.GetString("SaveSlot" + [2], ""); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables for checking and loading.
Using undefined variables.
✗ Incorrect
Both blanks use slotNumber to check and load the correct save slot.
5fill in blank
hardFill all three blanks to delete a save slot and confirm its removal.
Unity
PlayerPrefs.DeleteKey("SaveSlot" + [1]); if (!PlayerPrefs.HasKey("SaveSlot" + [2])) { Debug.Log("Save slot " + [3] + " deleted successfully."); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables causing mismatch.
Not checking if the key was deleted.
✗ Incorrect
All blanks use slotNumber to delete and confirm the correct save slot.