Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
:cookie: 137 | @garysiu |http://www.freecodecamp.com/garysiu
:cookie: 282 | @jonsnow08 |http://www.freecodecamp.com/jonsnow08
Gary Siu
Yeah everyone finds promises tough at first
Async in general too
@dagman someone mentioned that i could just get all streams at once through getjson
@dagman so GET /streams
then search through it to find the ones on my array
@max77p double check the api docs
Xavier Velez
@jianninetorres if you're finding those tough then the intermediate ziplines will be near impossible. Trust me on this, take your time
Jiannine Torres
how long did it take you guys to get through the basic algorithms, if I may ask?
I've got 5/16 done, but not without a little Googling for a couple of them
@wearenotgroot yea don't think it pulls every single stream, there seems to be a limit and on top of that, it seems like it just pulls the ones online
Islam Ibakaev
@max77p let them show how to do it
Edmund To
hello... can someone tell me why this doesn't work?
function findUser(data) { .....; $getJSON (URL, findData()) ) // declared findUser, calling findData
function findData (data) { ... $getJSON (URL, pushHTML()) } // declared findData, calling pushHTML()
function pushHTML(data) { ... } // declared pushHTML()
$(document).ready $(document).ready(
  function(){ ... for(i=0;i<array;i++) { //the array contains different URL
    $getJSON(array[i], findUser())
// what I expect: documentReady --> findUser --> findData --> pushHTML --> loop
// what happened: it loops, but all the content being pushed to the HTML is the same, data from the second last data I wanted to find in that array... why????
Greg Duncan
@edmundtfy in the loop it should be array.length - and you should never call an array 'array' call it 'arr' or even better 'channelsArr' - so the user can tell what is in it without having to search through your code
@max77p That's is basically how I did it
@GregatGit iterating through for loop?
Greg Duncan
@max77p yes
@GregatGit ok sweet, thanks!
max77p sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 695 | @gregatgit |http://www.freecodecamp.com/gregatgit
Edmund To
@GregatGit sorry I just typed that up, I used array.length in the code
Greg Duncan
@max77p If they are online when you do the call - then everything you need is brought down in that call - you can also access the channels api if they are offline through that call
@edmundtfy where is array defined
Edmund To
@GregatGit before everything, at the very top
Greg Duncan
@edmundtfy are you doing this in code pen
Edmund To
yes doing it in codepen as part of the Twitch.tv application
Greg Duncan
@edmundtfy can you post your pen
it's a bit of a mess..... @GregatGit
Greg Duncan
@edmundtfy don't forget to use the tidy button
@edmundtfy your naming in general is not good - one good example tho is pushHtml - I know exactly what it does just by reading the function name
@edmundtfy What is your main problem right now?
@GregatGit hey so i know using chromes console that my code is pulling info on the array of names i requested
however, for simplicity purposes all i am trying to do right now is output the status name of whatever is online, and then just output "offline" for whatever is offline on the page
or into my div
having a little trouble doing this though
i get the online status names to output, but not sure how to work the if statement so that the word "offline" is output below the two for the other ones
Edmund To
@GregatGit the entire thing being pushed to the HTML is wrong, you can't see it in your computer?
@GregatGit everything overlap on the same row, and everything being pushed is the same...
Greg Duncan
@edmundtfy I think you have made your pushHtml function to complicated
it should be simple
instead of using lots of jQuery to add classes and attribute - build a block of html like a string - then add (append) the block -
Greg Duncan
@edmundtfy a basic example
function buildHtml(img, class, address){
   var myHtml = '<div class="' + class + '">';
   myHtml += <a href="' + address // and keep building it

Greg Duncan
@max77p if (json.hasOwnProperty('error') check for errors (do nothing but console it if its there are there 'else if' check if(json.data === null) - now you know its offline - 'else' - its online
Edmund To
@GregatGit you are right I got it to go into the right format, but still, duplicating the same result...
Edmund To
@GregatGit seems like the variables aren't resetting: after I declare a certain value to a variable, it sticks for the first loop and doesn't change after the first loop...