How to fix code that returns undefined

ساخت وبلاگ

Vote count: 0

I have this code:

const liked_users = promises[1]; const disliked_users = promises[0]; if (liked_users.length > 0 || disliked_users.length > 0){ for(var i = 0; i < liked_users.length; i++){ for(var j = 0; j < disliked_users.length; j++){ for(var k = 0; k < _USERS.length; k++){ if(_USERS[k].useruid == liked_users[i].likedUseruid || disliked_users[j].dislikedUseruid){ _USERS.splice(i, 1); i--; break; }

basically what is happening is that I access the firebase database and I pull out some data from my objects. The problem comes where sometimes liked_users is going to be blank and therefore liked_users[i].likedUseruid will return undefined. When they are defined, the code runs fine. How can I put in some conditional or block of code that allows it to be read in a way that accepts it can be undefined or doesn't run the code until it is defined? I can show more code if it will help

asked 16 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : how to fix a zipper,how to fix a leaky faucet,how to fix pokemon go,how to fix your credit,how to fix a broken nail,how to fix a broken zipper,how to fix pokemon go gps,how to fix posture,how to fix anterior pelvic tilt,how to fix a hole in the wall, نویسنده : استخدام کار backsoft بازدید : 432 تاريخ : دوشنبه 29 شهريور 1395 ساعت: 11:33