Twitch Tv Project Last Glitch , Kindy guide

Twitch Tv Project Last Glitch , Kindy guide
0

#1

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


#2

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

var logo = ourData2.stream.channel.logo;

and following lines just aren’t executed.


#3

@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


#4

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


#5

@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)


#6

Works for me:


#7

@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


#8

Still works:


#9

@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