Retrieve value from nested functions javascript -
this question has answer here:
i have had look, , see great examples of nesting functions, reading them, cannot see why getting undefined when call function:
function readbttndetec() { var devid = localstorage.getitem('vbttn'); var bd = 0; bd = ble.read(devid, 'fffffff0-00f7-4000-b000-000000000000', 'fffffff2-00f7-4000-b000-000000000000', function(t) { var data = new uint8array(t) console.log('returns: ' + data[0]); // returns 6 return data[0]; }, function(f) { console.log(f); }); return bd; }
this call:
//check button state var detecs = readbttndetec(); console.log(detecs); if(detecs == 2) { // fall detection disabled $('#playfall').removeclass('km-state-active'); } else if(detecs == 6) { // fall detection enabled $('#playfall').addclass('km-state-active'); } else { // error reading button }
i missing simple sure of it, cannot see it.
thanks in advance
Comments
Post a Comment