Iterating over SQL data and appending to array


I am trying to make a login system with WebSQL. The sign up works. However, I want to make a function to see if I can see the usernames in an array. This is my code (I have a column for name and password):

var db = openDatabase('personDB', '1.0', 'the data of people', 2*1024*1024);
var exists=[];
db.transaction(function (tx) {
  tx.executeSql('SELECT * FROM people', [], function (tx, results) {
    var len = results.rows.length, i;
    for (i = 0; i < len; i++) {
return exists;

When I try it in a snap block, it doesn't report anything. Well, it reports something, but it reports a blank and empty array. However, when I try to do it in console, it works perfectly. Is there something I am doing wrong?

I'd appreciate it if I could get a quick response, because this is part of a project that is due tomorrow.

What code do you type in the console? Because when typing it into the console "return" throws an error since it isn't in a function.

I don't type return. I just print the exists array to the console.

Just replace


ok well I don't know how to make the database not empty. But I'm guessing it would because the function that receives the data is asynchronous meaning it runs later independent of what comes after, so it actually returns the value before filling it in with data. To fix this, you make the JavaScript function block return a function that returns a value. Then by using the wait until block with the returned JavaScript function, you can make it wait until the function returns a value. Like this:

I didn't actually test this code because I can't I don't know how SQL works.

If this works then I have no idea why it would work in the console.

I see what you are trying to do, but after transcribing, it won't stop. It appears to be stuck.

I had set it to a, so that isn't the problem.

value has to equal to a

so you can either replace all the value variables with "a", or replace all references to "a" with "value"

or is that sarcasm i can't tell

It was equal to a. I changed it after running to make it look good, but then I forgot.