the-collab-lab / tcl-36-smart-shopping-list

1 stars 2 forks source link

Refactoring/Creating Utility Functions #23

Closed lindseyindev closed 2 years ago

lindseyindev commented 2 years ago
// Assume we have the following data in the Database:
{
  "name": {
    "first": "Ada",
    "last": "Lovelace"
  }
}

// Test for the existence of certain keys within a DataSnapshot
var ref = firebase.database().ref("users/ada");
ref.once("value")
  .then(function(snapshot) {
    var a = snapshot.exists();  // true
    var b = snapshot.child("name").exists(); // true
    var c = snapshot.child("name/first").exists(); // true
    var d = snapshot.child("name/middle").exists(); // false
  });
lindseyindev commented 2 years ago

Make utility file and pull out functions and write comments for them as utilities