Twitch Tv Project Last Glitch , Kindy guide

Hi, thanks to the forum support i am now getting all the live streams by checking - ourData2.stream !== null, my code pen link here … https://codepen.io/jinisner/full/ZJVEgz/

But when i try - ourData2.stream === null and display accordingly , its not working can you guys please tell me where am i doing wrong … Thanks

If ourData2.stream is null you’ll get an error on:

var logo = ourData2.stream.channel.logo;

and following lines just aren’t executed.

1 Like

@jenovs - thanks for having a look at the code, as you can see even if i do not use logo , i use this condition for stream to be null -

else if(ourData2.stream === null){
console.log(“test”);
}

it does not execute, why is the control not reaching else if, is there any other closure like concept here also ?

Kindly guide …

Regards

If you don’t use logo there are still status and name which will fail.

@jenovs - i am not using any i am just trying to get a console print out, still no result, is there something wrong with - if (ourData2.stream !== null) because of which the control never goes to if (ourData2.stream === null)

Works for me:

@jenovs, the thing is if you do any thing in the first part of if statement it is working but not in the other part of else if, so the null part works if it is first but if it is in else if part it will not work and vice versa

Still works:

@jenovs - thanks a lot , i copied the - var logo = ourData2.stream.channel.logo;
var status = ourData2.stream.channel.status;
var name = ourData2.stream.channel.display_name;

inside the if () and it works well…

Seems the concept of closure at work again accessing there values and stop the loop as you said above , i have been working on other languages hence finding it hard to understand variable scope in javascript …

Thanks so much for your time …

Regards