I am working on a webpage that responds to a question with a random answer from a IDB store. There are currently 8 answers in the store, but I am planning on giving the user the option to add more. In order to determine the answer to respond with, I first want to be able to find the number of answers in the store.
var count = store.count()
var aCount = 0;
count.onsuccess=function() {
aCount = count.result;
console.log(aCount);
}
console.log(aCount);
Output:
0
8
For some reason the console.log outside of the success handler only outputs 0. Any ideas on how to fix this would greatly appreciated.