0
0
Firebasecloud~10 mins

Cloud Functions setup in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Firebase Cloud Functions.

Firebase
const functions = require('firebase-functions');
const admin = require('[1]');
Drag options to blanks, or click blank then click option'
Afirebase-admin
Bfirebase-functions
Cfirebase-tools
Dfirebase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'firebase-functions' instead of 'firebase-admin'.
Using 'firebase-tools' which is for CLI, not code.
2fill in blank
medium

Complete the code to export a simple HTTP Cloud Function named 'helloWorld'.

Firebase
exports.helloWorld = functions.[1].onRequest((request, response) => {
  response.send('Hello from Firebase!');
});
Drag options to blanks, or click blank then click option'
Afirestore
Bhttps
Cstorage
Dauth
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'firestore' or 'storage' which are for database or file triggers.
Using 'auth' which is for authentication triggers.
3fill in blank
hard

Fix the error in the code to initialize the Firebase Admin SDK.

Firebase
admin.[1]();
Drag options to blanks, or click blank then click option'
AinitApp
BstartApp
CcreateApp
DinitializeApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initApp' or 'startApp' which are not valid methods.
Using 'createApp' which is from other frameworks.
4fill in blank
hard

Fill both blanks to create a Firestore triggered Cloud Function that runs on document creation.

Firebase
exports.newUser = functions.firestore.document('[1]').[2]((snap, context) => {
  const newValue = snap.data();
  return null;
});
Drag options to blanks, or click blank then click option'
Ausers/{userId}
BonUpdate
ConCreate
DonDelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'onUpdate' or 'onDelete' which trigger on other events.
Using a path without a wildcard.
5fill in blank
hard

Fill all three blanks to create a scheduled Cloud Function that runs every day at midnight.

Firebase
exports.dailyJob = functions.pubsub.schedule('[1]').timeZone('[2]').onRun((context) => {
  console.log('[3]');
  return null;
});
Drag options to blanks, or click blank then click option'
Aevery 24 hours
BAmerica/New_York
CDaily job executed
Devery day at midnight
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'every 24 hours' which is valid but less clear than 'every day at midnight'.
Using incorrect timezone strings.
Logging unclear messages.