Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get the current user's UID.
Firebase
const userId = firebase.auth().currentUser.[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'email' instead of 'uid' will not give the unique user ID.
Trying to access 'displayName' when you want the user ID.
✗ Incorrect
The uid property uniquely identifies the user in Firebase Authentication.
2fill in blank
mediumComplete the code to update the user's display name in their profile.
Firebase
firebase.auth().currentUser.updateProfile({ displayName: [1] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable without quotes when a string is expected.
Using the property name instead of a string value.
✗ Incorrect
The updateProfile method expects an object with the new display name as a string.
3fill in blank
hardFix the error in the code to correctly fetch the user's email.
Firebase
const email = firebase.auth().currentUser.[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'emailAddress' or 'userEmail' which are not valid properties.
Trying to access 'mail' which does not exist.
✗ Incorrect
The correct property to get the user's email is email.
4fill in blank
hardFill both blanks to set the user's photo URL and then reload the user data.
Firebase
firebase.auth().currentUser.updateProfile({ photoURL: [1] }).then(() => { return firebase.auth().currentUser.[2](); }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name instead of a string for photoURL.
Calling a non-existent method like 'refresh' or 'update' instead of 'reload'.
✗ Incorrect
Use a string URL for photoURL and call reload() to refresh user data.
5fill in blank
hardFill all three blanks to create a user profile object with UID, email, and display name.
Firebase
const profile = { id: [1], email: [2], name: [3] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using phoneNumber instead of displayName for the name field.
Mixing up email and uid properties.
✗ Incorrect
Use uid for id, email for email, and displayName for name from the current user.