Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
function loops even though it shouldn't

With this function i want to insert data into my firebase database:

function insertDaten(titel) {
    var ref = firebase.database().ref();
    ref.on("value", function (snapshot) {
        var json_elemente = snapshot.val().notes;
        var keys = Object.keys(json_elemente);
        var count = Math.max.apply(null, keys) + 1;

        firebase.database().ref("notes/" + count).set({
            id: parseInt(count) + 1,
            text: "",
            titel: titel,
            bild: ""
    });
  });
}

but everytime i run it, it seems to loop and create as many datasets as it can before the program shuts down. i've tried to just add a return; but that doesn't seem to work either.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!