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