These are chat archives for FreeCodeCamp/HelpFrontEnd

4th
Apr 2016
Arjun Narayanan
@anarayanan86
Apr 04 2016 00:17
hey guys, im still unclear about the quote machine project
is it supposed to pull quotes from a website like wikiquotes?
or do we manually enter whatever quotes we want it to cycle through
Bruce Young
@mutantspore
Apr 04 2016 00:18
@anarayanan86 people have done both… though now the activity is later in the course so doing an API might be “more fun” lol
Arjun Narayanan
@anarayanan86
Apr 04 2016 00:19
hmm ok
Bruce Young
@mutantspore
Apr 04 2016 00:21
well it used to be before the lessons on APIs. Now it is after. but there are no instructions mentioning an api … so .. I know many campers just use an array
Arjun Narayanan
@anarayanan86
Apr 04 2016 00:25
like, they import the quotes from a website into a large array?
Bruce Young
@mutantspore
Apr 04 2016 00:27
no .. you can either use an api to grab a quote from a website each time the button is clicked (or a bunch I guess if the API allows it) or simply, as you said, assemble your own and put them in an array or an array of objects manually.
Arjun Narayanan
@anarayanan86
Apr 04 2016 00:29
heh
the API method would be more fun, but more challenging
you would have to fix the formatting and layout
Bruce Young
@mutantspore
Apr 04 2016 00:30
yes you’ll need to know it anyway for the rest of those activities
Arjun Narayanan
@anarayanan86
Apr 04 2016 00:32
oh man
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 00:59
need some help with weather api project.. im working on changing my background image based on a certain json object.. can anyone take a look? So far its telling me i have an invalid string..
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:06
anyone?
Bruce Young
@mutantspore
Apr 04 2016 01:09
@Dueldrawer8 well for me it doesn’t get past “loading…"
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:09
correct
Ori Bernstein
@OriBern
Apr 04 2016 01:10
How do i get around the backslash problem in the palindrome algorithm challenge?
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:10
 function backGround(weatherCond) {
        var conditions = {
            'Clear': function() {
              // checks to see if icon is night, if not its day and display else statment
              if (weatherDayNight.search('n') != -1) {
                $('body').css('background-image', 'url("https://web-assets.domo.com/blog/wp-content/uploads/2012/12/nighttimesky.jpeg")');
              } else {
                $('body').css('background-image', 'url("http://wfiles.brothersoft.com/b/blue-sky-with-clear-water_175256-1600x1200.jpg")');
              }
            },
            'Thunderstorm': function() {
              if (weatherDayNight.search('n') != -1) {
                $('body').css('background-image', 'url("http://s3.amazonaws.com/rapgenius/1367403834_night-thunder-storm-lightning.jpg")');
              } else {
                $('body').css('background-image', 'url("http://www.prevention.com/sites/prevention.com/files/images/news/featured_images/thunderstorm-628x363-TS-135165621_0.jpg")');
              }
            },
            'Rain': function() {
              if (weatherDayNight.search('n') != -1) {
                $('body').css('background-image', 'url("http://alm0na.files.wordpress.com/2012/01/rain_drops_at_night-wide.jpg")');
              } else {
                $('body').css('background-image', 'url("http://www.pureella.com/wp-content/uploads/2011/04/pleasurefeelingpeoplephotographyarm.jpg")')
              }
            },
            'Snow': function() {
              $('body').css('background-image', 'url("https://img.buzzfeed.com/buzzfeed-static/static/2014-01/enhanced/webdr07/24/6/anigif_enhanced-buzz-2717-1390562645-0.gif")')
            }
          },
          'Clouds': function(){
            $('body').css('background-image', 'url("http://icons.wunderground.com/data/wximagenew/1/1photogirl93/29-800.jpg")')
          }
       };
        if(typeof conditions[weatherCond]!== 'function'){
          $('body').css('background-image', 'url("https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTNQzaAiOTFK70eqtdoaKTdMR63raFj-By0SklV6ixQPyTqt6_I")')
        }
     };
i dont think that code is right
if (weatherDayNight.search('n') != -1) {
                $('body').css('background-image', 'url("https://web-assets.domo.com/blog/wp-content/uploads/2012/12/nighttimesky.jpeg")');
              } else {
                $('body').css('background-image', 'url("http://wfiles.brothersoft.com/b/blue-sky-with-clear-water_175256-1600x1200.jpg")');
              }
            },
is that the correct way to display a background image using jquery?
apklip
@apklip
Apr 04 2016 01:15
All the offline channels for my twitch.json viewer return errors in the console.log
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:17
@mutantspore try now... background doesnt change still http://codepen.io/duel_drawer8/pen/bpoozL?editors=1111
nvm..still doesnt work
Bruce Young
@mutantspore
Apr 04 2016 01:20
@Dueldrawer8 really I can’t get it to do anything .. if you use the [Analyze JS] button in teh JS cog you’ll get a big list of issues
@Dueldrawer8 to do the same thing I just used a big array of objects
var weatherPic = {};
weatherPic['01d'] = {
  'picURL': 'https://farm6.staticflickr.com/5547/10236509126_beb2653f30_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/20980483@N04/10236509126'
};
weatherPic['01n'] = {
  'picURL': 'https://farm9.staticflickr.com/8013/7425650562_408d11b32a_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/anieto2k/7425650562'
};
weatherPic['02d'] = {
  'picURL': 'https://farm4.staticflickr.com/3300/4624340515_86e70eac1f_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/p1k3/4624340515'
};
weatherPic['02n'] = {
  'picURL': 'https://farm9.staticflickr.com/8523/8555575607_9ebc6f054e_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/theilr/8555575607'
};
weatherPic['03d'] = {
  'picURL': 'https://farm9.staticflickr.com/8041/8063337716_19dcbdf5b1_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/21078769@N00/8063337716'
};
weatherPic['03n'] = {
  'picURL': 'https://farm5.staticflickr.com/4145/4991381941_8bb81ac04a_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/jeffpang/4991381941'
};
weatherPic['04d'] = {
  'picURL': 'https://farm8.staticflickr.com/7533/15734894479_fea01a4076_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/richardwalkerphotography/15734894479'
};
weatherPic['04n'] = {
  'picURL': 'https://farm4.staticflickr.com/3169/5800040969_f600d30443_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/nggalai/5800040969'
};
weatherPic['09d'] = {
  'picURL': 'https://farm3.staticflickr.com/2641/3685710828_9ab14be153_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/cleopold73/3685710828'
};
weatherPic['09n'] = {
  'picURL': 'https://farm5.staticflickr.com/4056/4550059678_c0ae4ce1e1_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/jhritz/4550059678'
};
weatherPic['10d'] = {
  'picURL': 'https://farm3.staticflickr.com/2497/3908596608_94a2e0d3a1_o.jpg',
  'whoURL': 'https://www.flickr.com/photos/geishabot/3908596608'
};
weatherPic['10n'] = {
  'picURL': 'https://farm3.staticflickr.com/2220/1815415291_99511c61f6_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/almaz73/1815415291'
};
weatherPic['11d'] = {
  'picURL': 'https://farm8.staticflickr.com/7353/10612586044_70e7d67ed2_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/emiliokuffer/10612586044'
};
weatherPic['11n'] = {
  'picURL': 'https://farm1.staticflickr.com/118/291628090_c818848f82_o.jpg',
  'whoURL': 'https://www.flickr.com/photos/colinedwards/291628090'
};
weatherPic['13d'] = {
  'picURL': 'https://farm3.staticflickr.com/2827/12019505223_fd58ae4344_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/calliope/12019505223'
};
weatherPic['13n'] = {
  'picURL': 'https://farm9.staticflickr.com/8592/16546369800_19acf40ec5_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/nudelbach/16546369800'
};
weatherPic['50d'] = {
  'picURL': 'https://farm8.staticflickr.com/7457/10633539226_0580cfecfe_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/schmollmolch/10633539226'
};
weatherPic['50n'] = {
  'picURL': 'https://farm8.staticflickr.com/7463/15705235150_dac893a4b0_b.jpg',
  'whoURL': 'https://www.flickr.com/photos/ericmilet/15705235150'
};
Carlos Pulido
@carlosfrontend
Apr 04 2016 01:23
hi :)
somebody can help me ?
im working in the portfolio
i have a problem with the section portfolio
Bruce Young
@mutantspore
Apr 04 2016 01:24
@Dueldrawer8 same for the weather icons font
var icons = {};
icons['01d'] = 'sun';
icons['01n'] = 'moon';
icons['02d'] = 'cloud sun';
icons['02n'] = 'cloud moon';
icons['03d'] = 'cloud';
icons['03n'] = 'cloud';
icons['04d'] = 'cloud';
icons['04n'] = 'cloud';
icons['09d'] = 'showers';
icons['09n'] = 'showers';
icons['10d'] = 'rain sun';
icons['10n'] = 'rain moon';
icons['11d'] = 'lightning sun';
icons['11n'] = 'lightning moon';
icons['13d'] = 'snow sun';
icons['13n'] = 'snow moon';
icons['50d'] = 'fog sun';
icons['50n'] = 'fog moon’;
Carlos Pulido
@carlosfrontend
Apr 04 2016 01:25
need center in bootstrap the thumnails containers of projects and do it responsives
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:25
@mutantspore thats most efficient way to do it?
Bruce Young
@mutantspore
Apr 04 2016 01:25
just used the weather icon to look it up.
$(".full").css("background-image", "url(" + thePicURL + ")”);
var thePicURL = weatherPic[data.weather[0].icon].picURL;
no searching ,no reapeating code
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:30
@mutantspore couple of things.. you said you used a big array of objects.. your declaration is var = { } rather than [ ]..so its a big array of objects within objects?
Greg Duncan
@GregatGit
Apr 04 2016 01:31
@Dueldrawer8 It looks like you have a a few syntax errors
Bruce Young
@mutantspore
Apr 04 2016 01:31
ok if you like
@GregatGit @Dueldrawer8 yes I suggested the use of Analyze JS .
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:31
@GregatGit yeah i checked it out and tried correcting some of them.. its way to many and dont know where to start.. i even placed semi colons where they belong and still said i had semi colon issues
@mutantspore same thing i suppose :)
Greg Duncan
@GregatGit
Apr 04 2016 01:32
@Dueldrawer8 Your background function - where should it end?
Bruce Young
@mutantspore
Apr 04 2016 01:33
@Dueldrawer8 I have the pic URL and a link to the person who took the pic .. just to be nice
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:33
@GregatGit i believe line 90..
i want that last if statement contained inside the function
@mutantspore ah, yes was wondering what that was
@mutantspore thanks for the Analyze JS
CamperBot
@camperbot
Apr 04 2016 01:34
dueldrawer8 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1352 | @mutantspore | http://www.freecodecamp.com/mutantspore
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:34
and suggestion which i may do
Greg Duncan
@GregatGit
Apr 04 2016 01:35
@Dueldrawer8 I would pull everything out of the background function and put them back in one by one
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:35
@GregatGit am i correctly using the .css() selector on the background images?
Greg Duncan
@GregatGit
Apr 04 2016 01:36
yes
Patrick
@pwcsquared
Apr 04 2016 01:37
Hey guys, I'm looking for some input on my twitch app. It's basically done and working totally fine, but my fiancee says it looks very "web 1.0" lol
I'm open to design suggestions, I want it to look slick and hip hehe
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:38
@GregatGit okay ill try to put everything back in.. it even went so far to say i needed to name that background function
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:43
is this not right?
Greg Duncan
@GregatGit
Apr 04 2016 01:43
@Dueldrawer8 Use the tidy button in the code pen -
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:43
function backGround(weatherCond){
        var conditions = {
                      'Clear': function() {
                        if (weatherDayNight.search('n') != -1) {
                $('body').css('background-image', 'url("https://web-assets.domo.com/blog/wp-content/uploads/2012/12/nighttimesky.jpeg")');
                      }


        };
      }
says unexpected token ;.
yet when i take the code inside of conditions out.. it is fine
Greg Duncan
@GregatGit
Apr 04 2016 01:44
delelete the token
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:45
@GregatGit ok
@GregatGit this makes no sense
if(weatherDayNight.search('d') != -1) {
                $('body').css('background-image', 'url("http://wfiles.brothersoft.com/b/blue-sky-with-clear-water_175256-1600x1200.jpg")');
the ) at the very end.. its telling me unexpected token
doesnt it have to match the .css( ?
if i dont im not enclosing it
Greg Duncan
@GregatGit
Apr 04 2016 01:49
@Dueldrawer8 your syntax just went a little crazy
@Dueldrawer8 try this
function backGround(weatherCond) {
    var conditions = {
        'Clear': function() {
          // checks to see if icon is night, if not its day and display else statment
          if (weatherDayNight.search('n') != -1) {
            $('body').css('background-image', 'url("https://web-assets.domo.com/blog/wp-content/uploads/2012/12/nighttimesky.jpeg")');
          }
          if (weatherDayNight.search('d') != -1) {
            $('body').css('background-image', 'url("http://wfiles.brothersoft.com/b/blue-sky-with-clear-water_175256-1600x1200.jpg")');
          }
        },
        'Thunderstorm': function() {
          if (weatherDayNight.search('n') != -1) {
            $('body').css('background-image', 'url("http://s3.amazonaws.com/rapgenius/1367403834_night-thunder-storm-lightning.jpg")');
          }
          if (weatherDayNight.search('d') != -1) {
            $('body').css('background-image', 'url("http://www.prevention.com/sites/prevention.com/files/images/news/featured_images/thunderstorm-628x363-TS-135165621_0.jpg")');
          }
        },
        'Rain': function() {
          if (weatherDayNight.search('n') != -1) {
            $('body').css('background-image', 'url("http://alm0na.files.wordpress.com/2012/01/rain_drops_at_night-wide.jpg")');
          }
          if (weatherDayNight.search('d') != -1) {
            $('body').css('background-image', 'url("http://www.pureella.com/wp-content/uploads/2011/04/pleasurefeelingpeoplephotographyarm.jpg")')
          }
        },
        'Snow': function() {
          $('body').css('background-image', 'url("https://img.buzzfeed.com/buzzfeed-static/static/2014-01/enhanced/webdr07/24/6/anigif_enhanced-buzz-2717-1390562645-0.gif")');
        },
      'Clouds': function() {
        $('body').css('background-image', 'url("http://icons.wunderground.com/data/wximagenew/1/1photogirl93/29-800.jpg")');
      }
      }
  };
but keep a copy of your last
your mistakes are small but they can be quite frustrating
Tien Anh Nguyen
@tienanh2007
Apr 04 2016 01:55
how do I import this weather icons into my css ?
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:55
@GregatGit hm.. i see where i messed up.. couple semi colons
let me try it out and see if it works
apklip
@apklip
Apr 04 2016 01:56
My console is returning errros. http://codepen.io/DarkPigeons/pen/grGBWM
nsloc22
@nsloc22
Apr 04 2016 01:56
who can break my calculator http://codepen.io/nsloc22/full/ONxGxe/
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 01:59
@GregatGit i compared mistakes corrected them and no syntax errors.. now my background images are not showing up
Tien Anh Nguyen
@tienanh2007
Apr 04 2016 01:59
@tienanh2007
how do I import this weather icons into my css ?
https://erikflowers.github.io/weather-icons/
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:00
does it not go in my .ajax function?
Bruce Young
@mutantspore
Apr 04 2016 02:00
@nsloc22 so why no decimal point?
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:01
nvm got it to work..except wrong weather cond
Greg Duncan
@GregatGit
Apr 04 2016 02:04
@Dueldrawer8 here is a fork of your work http://codepen.io/gregoverhere/pen/qZPzpq?editors=0011
I'm not sure what you've done - but here it is working
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:05
@GregatGit look at this one..
mine shows a background img of clear but its showing the last if case which is basically the default case
Bruce Young
@mutantspore
Apr 04 2016 02:06
@Dueldrawer8 lol the weather says “clear” yet I get a picture of a hurricane!
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:06
yes..
haha
trying to fix that!
lol
Greg Duncan
@GregatGit
Apr 04 2016 02:07
@Dueldrawer8 did you use his code?
Tien Anh Nguyen
@tienanh2007
Apr 04 2016 02:07
@mutantspore thank you.
CamperBot
@camperbot
Apr 04 2016 02:07
tienanh2007 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1353 | @mutantspore | http://www.freecodecamp.com/mutantspore
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:07
whose code?
the forked code?
Greg Duncan
@GregatGit
Apr 04 2016 02:08
the pen of randolph goldsmith
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:08
yes im randolph goldsmith
lol
or randy
Greg Duncan
@GregatGit
Apr 04 2016 02:09
hahahah!
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:09
im so confused :/
Greg Duncan
@GregatGit
Apr 04 2016 02:09
You are too!
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:10
but yes on that earlier one i actually set a background image in the css
then i took it out since i technically "declare" or assign a background image through jQuery
now the problem is why wont the correct case.. or background img project into the html
Greg Duncan
@GregatGit
Apr 04 2016 02:11
Have a look at this pen, it's yours but it is working http://codepen.io/gregoverhere/pen/qZPzpq?editors=0011
Have you ever use brake points in the google chrome
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:13
its not working, thats the set background I had just to use a placeholder. Its in my CSS tab not the JS tab.. so in my clear case.. its a different pic therefore it is not working
as @mutantspore said.. he is getting a background img
but its of the wrong case.. its of the other cases or default case.. when it should follow the background img from the clear case..its not the same pic
Greg Duncan
@GregatGit
Apr 04 2016 02:15
@Dueldrawer8 Why don't you use a simple switch() in your backGround function?
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:16
its basically the same thing.. i just heard we should try to avoid using switch statments if possible
my code works
its just im missing something
Bruce Young
@mutantspore
Apr 04 2016 02:18
@Dueldrawer8 yes but you have a lot of repeated code.. and as you can see it’s hard to debug.
Greg Duncan
@GregatGit
Apr 04 2016 02:18
@Dueldrawer8 I'm just going to have a look at css for a moment
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:18
@mutantspore yes
i just thought creating objects would be easier than switch statements
@mutantspore could i stick this
if (weatherDayNight.search('n') != -1)
without the if part into a variable to make it easier to read?
within the function
@GregatGit sure
Bruce Young
@mutantspore
Apr 04 2016 02:20
@Dueldrawer8 well as I showed earlier I used an array of objects, used the weather icon as the index and one line of jquery to change the css.. no switch, no functions, no repeated code
Greg Duncan
@GregatGit
Apr 04 2016 02:21
@Dueldrawer8 Sorry Randy - with all this messing around i have forgotten the issue?
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:22
may have to do it that way :)
@GregatGit no worries
@GregatGit the first issue was making sure a background img is projecting into the html which it is
Greg Duncan
@GregatGit
Apr 04 2016 02:23
And now?
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:23
@GregatGit now, im trying to match the RIGHT background image to my weatherCond
it shows a background.. but its only for the last case within my backGround function
its suppose to be the case for the 'Clear' function
Bruce Young
@mutantspore
Apr 04 2016 02:25
@Dueldrawer8 case sensitive?
Greg Duncan
@GregatGit
Apr 04 2016 02:25
So you are getting the correct condition?
rain/cloulds/whatever
sudama101
@sudama101
Apr 04 2016 02:27
im still trapped to the tribute page
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:28
correct
@mutantspore hmm.. ill check it out
it shows it capital letter.. like if its clear.. its Clear
in my object i specifically put 'Clear"
console.log(weatherCond) = "Clear"
Greg Duncan
@GregatGit
Apr 04 2016 02:33
@Dueldrawer8 The functions in backGround are not firing when needed. Just put a simple alert('cloulds'); or what ever you area is and you will see that nothing is happing
Dominic Lobban
@alkapwn3d
Apr 04 2016 02:34
anyone have anyluck on craigslist?
Greg Duncan
@GregatGit
Apr 04 2016 02:35
@Dueldrawer8 You have not set them up to be accessed correctly
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:36
@GregatGit yes, i was console.logging trying to figure out the problem.. how would i do that?
Greg Duncan
@GregatGit
Apr 04 2016 02:36
@Dueldrawer8 for now instead of an just use simple if conditions (make it pretty later)
so if weatherCond === "clouldy" do this
else if weather Cond === "rain" so this and so on
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:38
@GregatGit thanks
CamperBot
@camperbot
Apr 04 2016 02:38
dueldrawer8 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:star: 393 | @gregatgit | http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Apr 04 2016 02:38
or a switch, but loose the conditions object
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:38
i think im mkaing it more complicated that need be
yes
Greg Duncan
@GregatGit
Apr 04 2016 02:38
Good luck I have to go but I'm going to check up on it - I'm curious to see how it pans out
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:39
@GregatGit :) thanks again! i may just do it the way mutant spore suggested!
CamperBot
@camperbot
Apr 04 2016 02:39
dueldrawer8 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave gregatgit points
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:39
@mutantspore cool? lol
Greg Duncan
@GregatGit
Apr 04 2016 02:39
Get it working then get pretty!
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:40
will do
Greg Duncan
@GregatGit
Apr 04 2016 02:43
the only thing that has to change is the myUrl
$('body').css('background-image', 'url(myUrl)');
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:44
yeah gong to have to store those urls in variable
A. J. Bozdar
@moajday
Apr 04 2016 02:49
Can someone explain me this code?
<meta name="viewport" content="width=device-width, initial-scale=1.0"> Thanks in advance. :smile:
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 02:52
@mutantspore if i do what you did with weatherPic how you made it into an object.. what if i want to store mutiple weatherconditions to one weatherPic
means what if i wanted to store 01d, 05d, 10n taken as an example and apply it all to one pic
still declare them all separately and just put the url as you did?
Eric Murta
@murtinha
Apr 04 2016 03:02
function smallestCommons(arr) {
  var check=0;
  var x=0;
  var value=Math.max(arr[0],arr[1]);
  var maxval=Math.max(arr[0],arr[1]);
  var cond=(Math.max(arr[0],arr[1])-(Math.min(arr[0],arr[1])))+1;

  while(x===0){
      check=0; 
    for(i=Math.min(arr[0],arr[1]);i<=maxval;i++){
      if((value%i)===0){
        check++;

      }
    }

    if(check==cond){
      x=1;       
    }
    else{
      value++;
    }

    }

  return value;
}


smallestCommons([1,12]);
Guys, on challenge smalest common multiple, my logic is working fine for number untill 12, if a put 13 there my loop becomes infinite...
narkeeta
@narkeeta
Apr 04 2016 03:15
can anyone tell me why my javascript isnt working when I click play right now
Dustin
@Key-Banger
Apr 04 2016 03:20
@murtinha I don't know for sure, like I said I haven't done this one. but if your (value%i)!==0then maybe that keeps running.
Javier Sanchez
@javiermxmd
Apr 04 2016 03:20
http://codepen.io/jay30/pen/ZWXRrM i just finished this what do you think ?
Eric Murta
@murtinha
Apr 04 2016 03:22
@Key-Banger the thing is it works for all numbers less then 13 hahaha, when I put any number higher than that it loops infinite...
narkeeta
@narkeeta
Apr 04 2016 03:27
I fixed my question
Dustin
@Key-Banger
Apr 04 2016 03:35
@murtinha The if check == cond isn't firing for 13. It fires for 12. I also changed the while to if to try and prevent crashing the browser. I dont know if that helps. Just my observation.
Patrick
@pwcsquared
Apr 04 2016 03:37
@javiermxmd weeeell it should be "new quote" not "new qoute"
but it looks nice, the text box maybe doesn't need to be so wide
Eric Murta
@murtinha
Apr 04 2016 03:38
@Key-Banger if you return cond up there on th declaration its igual to 13 actually
Dustin
@Key-Banger
Apr 04 2016 03:40
@murtinha yea, but maybe because that isn't firing the value++ is which changes your while loop.
Michael Aubrey
@mca62511
Apr 04 2016 03:41
hey, working on the pomodoro clock. I'm thinking about making an animation that shrinks and hides the options when the clock starts (while expending the top yellow bar)
http://codepen.io/mca62511/pen/qZPGwE?editors=1100
However, I can't get height: 0 to actually give it no height
any ideas why?
Eric Murta
@murtinha
Apr 04 2016 03:43
@Key-Banger the thing is, if you set value=360360 that is the result and then return check, check is actually iguals 13...
Jeff
@adzam5
Apr 04 2016 03:46
@mca62511 No idea why height: 0 wont work. Why not use display: none?
Michael Aubrey
@mca62511
Apr 04 2016 03:46
@adzam5 Because eventually I want to make it animate the current height to zero
Jeff
@adzam5
Apr 04 2016 03:47
@mca62511 You can use .slideUp()
Michael Aubrey
@mca62511
Apr 04 2016 03:48
@adzam5 Let me try that
@adzam5 Awesome, that worked, thanks
CamperBot
@camperbot
Apr 04 2016 03:48
mca62511 sends brownie points to @adzam5 :sparkles: :thumbsup: :sparkles:
:star: 383 | @adzam5 | http://www.freecodecamp.com/adzam5
Jeff
@adzam5
Apr 04 2016 03:49
@mca62511 Cool! Glad I could help
Dustin
@Key-Banger
Apr 04 2016 03:50
@murtinha yea, I dont know. If check and cond aren't === the value might just keep incrementing.
@murtinha it also wont change x. so While x===0 stays true.
Eric Murta
@murtinha
Apr 04 2016 03:57
@Key-Banger yeah that might be the error... but how to fix it? hahaha
Dustin
@Key-Banger
Apr 04 2016 03:59
@murtinha wish I could help you there. I'm trying to figure it out too.
Eric Murta
@murtinha
Apr 04 2016 04:03
@Key-Banger thanks a lot man for your time
CamperBot
@camperbot
Apr 04 2016 04:03
murtinha sends brownie points to @key-banger :sparkles: :thumbsup: :sparkles:
:star: 373 | @key-banger | http://www.freecodecamp.com/key-banger
Dustin
@Key-Banger
Apr 04 2016 04:06
@murtinha no worries. Thanks for the head start!
CamperBot
@camperbot
Apr 04 2016 04:06
key-banger sends brownie points to @murtinha :sparkles: :thumbsup: :sparkles:
:star: 295 | @murtinha | http://www.freecodecamp.com/murtinha
Michael Aubrey
@mca62511
Apr 04 2016 04:12
@adzam5 Hey, the animation is working nicely now, so thanks again
CamperBot
@camperbot
Apr 04 2016 04:12
mca62511 sends brownie points to @adzam5 :sparkles: :thumbsup: :sparkles:
:warning: mca62511 already gave adzam5 points
narkeeta
@narkeeta
Apr 04 2016 04:23
Can someone help me, in my simon game when I use while loops or for loops it brakes the code causing it to stall my browser when I hit play in the game. Can someone look at my code and tell me how to fix this.
narkeeta
@narkeeta
Apr 04 2016 04:43
nevermind on my question
Shivam Arora
@shivamarora13
Apr 04 2016 06:16
I can't access my gloabal array in a method, with index number
can anybody help?
Steven Parker
@Philosophist
Apr 04 2016 06:24

One last discrepancy to fix on my Simon game: It seems to be taking too long to load the font for the score/count board. When I hit ON/OFF, the first thing posted is a 0 in the wrong font and slightly sticking out of the score board, then each subsequent update uses the correct font. The initial piece sticking out remains, since I never redraw outside of the board after that. I can think of a lot of workarounds to this, but it seems to me that there would be a way to just make the computer load the text completely before proceeding with the first 0. Does anyone know how to do that?

http://codepen.io/Philosophist/full/yOMOmV/

Steven Parker
@Philosophist
Apr 04 2016 06:32
@shivamarora13 Can you post a link to your code so that I can take a look?
Shivam Arora
@shivamarora13
Apr 04 2016 06:33
Brian Daub
@briandaub
Apr 04 2016 06:36
Hey guys I am wondering if anyone decided to just use a template instead of designing their portfolio? I am not that great at design and I never finish my portfolio because I am unhappy with the results. I want to host it on github and use jekyll to host a blog and create a contact form as well, so I am doing a lot of my own work….but I am still unsure about using a template. Any thoughts?
Yeah idk. I guess it’s a stupid question. I should just figure out the design on my own and code it...
Shivam Arora
@shivamarora13
Apr 04 2016 06:43
@Philosophist ?
kirbyedy
@kirbyedy
Apr 04 2016 06:46
@briandaub look around the internet, find something you like, and try to make something similar on your own
Steven Parker
@Philosophist
Apr 04 2016 06:47
@shivamarora13 I'm having trouble understanding the problem as well. I think the issue is that you are declaring your variables outside of the $(document).ready() function.
None of them are recognized (turned blue) unless they are declared inside of $(document).ready()
However, my guess is that they should still operate if called within $(document).ready()
Yeah, none of your declarations are defined outside of it.
Vlad
@avlads
Apr 04 2016 06:50

hi! i`m stuck at javascript testing object for properties

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("gift")){
return myObj[gift];
}
else if(myObj.hasOwnProperty("pet")){
return myObj[pet];
}
else if(myObj.hasOwnProperty("bed")){
return myObj[bed];
}
else{
return "Not Found!";
}
return "Change Me!";
}
i need some help
with the code

Shivam Arora
@shivamarora13
Apr 04 2016 06:50
@Philosophist ok lemme try thanks!
CamperBot
@camperbot
Apr 04 2016 06:50
shivamarora13 sends brownie points to @philosophist :sparkles: :thumbsup: :sparkles:
:star: 382 | @philosophist | http://www.freecodecamp.com/philosophist
Greg Duncan
@GregatGit
Apr 04 2016 07:08
@avlads you should be using checkProp varible in the checkObj function
@avlads so it should be more like if(myObj.hasWonProperty(checkProp)
Vlad
@avlads
Apr 04 2016 07:10
i will try now
Greg Duncan
@GregatGit
Apr 04 2016 07:10
not if(myObj.hasWonProperty("gift")
Bruce Young
@mutantspore
Apr 04 2016 07:10
lol .hasOwnProperty
Greg Duncan
@GregatGit
Apr 04 2016 07:10
haha
Bruce Young
@mutantspore
Apr 04 2016 07:11
I know… a typo but before it gets copied
:)
Vlad
@avlads
Apr 04 2016 07:12
and the code must be something like this
if (myObj.hasOwnProperty(checkProp)){
return myObj["checkProp"];
}
else {
return "Not Found";
}
?
Greg Duncan
@GregatGit
Apr 04 2016 07:12
looks better
Vlad
@avlads
Apr 04 2016 07:13
not working :(
Greg Duncan
@GregatGit
Apr 04 2016 07:15
what is the problem called?
Vlad
@avlads
Apr 04 2016 07:16
return myObj["checkProp"]; this was the problem
:D
Greg Duncan
@GregatGit
Apr 04 2016 07:17
no - the name of the FCC challenge you're working on
Bruce Young
@mutantspore
Apr 04 2016 07:17
yes, like to see what I did lol
Greg Duncan
@GregatGit
Apr 04 2016 07:18
Yeah!
Bruce Young
@mutantspore
Apr 04 2016 07:18
@avlads name of the actual challenge please
Vlad
@avlads
Apr 04 2016 07:19
Testing Objects for Properties
Greg Duncan
@GregatGit
Apr 04 2016 07:21
I basically did what you did there - just no ""
Bruce Young
@mutantspore
Apr 04 2016 07:21
@avlads remove the quotes in return myObj["checkProp"];
adityac0620
@adityac0620
Apr 04 2016 07:21
function convert(celsius) {
  // Only change code below this line
  var celcius;
  var farenheit= celcius*(9/5)+32;
  return farenheit;
  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}

// Change the inputs below to test your code
convert(0);

To test your learning you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

these are the objectives
pls help
challenge name "Convert Celcius To Farenheit"
Greg Duncan
@GregatGit
Apr 04 2016 07:23
@adityac0620 You declared celcius
delete the line var celcius;
rahulkavi
@rahulkavi
Apr 04 2016 07:24
Hello, someone help me in solving Roman Numeral Converter challenge ..
adityac0620
@adityac0620
Apr 04 2016 07:24
tried that too @GregatGit
it gives error 'variable not defined''
Michael Aubrey
@mca62511
Apr 04 2016 07:25
what is the standard folder name to put audo files in? Like JavaScript is usually "js", css is usually "css", images is usually "img"
audio?
Greg Duncan
@GregatGit
Apr 04 2016 07:26
@adityac0620 celcius is the argument - it gets defined when you put it in you can't then create a variable called celcius
@adityac0620 You have typos - you haven't spelt everything the same
adityac0620
@adityac0620
Apr 04 2016 07:29
function convert(celsius) {
  // Only change code below this line
  var farenheit= celcius*(9/5)+32;
  return farenheit;
  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}
// Change the inputs below to test your code
convert(0);
Bruce Young
@mutantspore
Apr 04 2016 07:30
@adityac0620 kill that first return farenheight;
Greg Duncan
@GregatGit
Apr 04 2016 07:30
@adityac0620 fahrenheit - not farenheight
and you don't the code already has a return in it - you don't need to put one
Bruce Young
@mutantspore
Apr 04 2016 07:32
@mca62511 i’ve just used ‘audio’ though some may use ‘media'
Michael Aubrey
@mca62511
Apr 04 2016 07:32
@mutantspore Thanks for the response.
CamperBot
@camperbot
Apr 04 2016 07:32
mca62511 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1357 | @mutantspore | http://www.freecodecamp.com/mutantspore
adityac0620
@adityac0620
Apr 04 2016 07:33
function convert(celsius) {
  // Only change code below this line
  var farenheit= celcius*(9/5)+32;
  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}
// Change the inputs below to test your code
convert(0);
Greg Duncan
@GregatGit
Apr 04 2016 07:33
@adityac0620 You spelt fahrenheit wrong
the function returns 'fahrenheit' not 'farenheit' and its 'celsius' not 'celcius'
Bruce Young
@mutantspore
Apr 04 2016 07:35
@GregatGit nice to see ‘spelt’ .. they all say ‘spelled’ here
adityac0620
@adityac0620
Apr 04 2016 07:36
@GregatGit thanks a lot .
CamperBot
@camperbot
Apr 04 2016 07:36
adityac0620 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:star: 394 | @gregatgit | http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Apr 04 2016 07:36
@adityac0620 notice how the they are white - they should be a light blue
adityac0620
@adityac0620
Apr 04 2016 07:36
ive got through
Greg Duncan
@GregatGit
Apr 04 2016 07:36
cool
@mutantspore Haha! You spelt 'spelt' 'spelled' instead of 'spelt'
Bruce Young
@mutantspore
Apr 04 2016 07:40
@GregatGit yes I am a bit sick of hearing spelled really. I wince everytime I hear it
@rahulkavi sorry, my solutiion is probably unique and I’d not like to see it public lol
@rahulkavi you are best to go to the HelpJavaScript room
Bruce Young
@mutantspore
Apr 04 2016 07:45
rooms
CamperBot
@camperbot
Apr 04 2016 07:45

rooms

See all the FreeCodeCamp rooms at gitter.im/FreeCodeCamp/rooms
Or check this wiki article for a shortlist
KortsF
@KortsF
Apr 04 2016 07:47
Would anybody help me understand why the JS code between lines 30 and 40 of my Pen (http://codepen.io/KortsF/pen/ZWyqZE) doesn't work to update the background image according to weather conditions?
The weather ID in my location today is 501 (I checked b y logging it to the console), so it should be picking up the image specified in the else if statement on line 35.
Greg Duncan
@GregatGit
Apr 04 2016 07:50
@KortsF Small tip - use the tidy button to help make you code more readable and where do the numbers, like 501, come from
KortsF
@KortsF
Apr 04 2016 07:53
@GregatGit Thank you, yes, I know I have to work on that. I'm using the openweathermap API, and 501 is the first value in the weather array within the JSON element returned by the API as specified here http://openweathermap.org/current
CamperBot
@camperbot
Apr 04 2016 07:53
kortsf sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:star: 395 | @gregatgit | http://www.freecodecamp.com/gregatgit
KortsF
@KortsF
Apr 04 2016 07:55
I'm using the same value (that I assigned to a variable called codIcon) to update the weather conditions icon on line 24, and it works, so there must be someting wrong with the bit of code I wrote to update the background image?
Bruce Young
@mutantspore
Apr 04 2016 08:01
@KortsF all I can say is “it works for me"
KortsF
@KortsF
Apr 04 2016 08:04
@mutantspore Is it sunny overthere? Is it uploading the photo of the lake with the sun on the right? I've been thinking it worked because we had sunny weather for the last few days here and I was seeing that image (the first one in the if/else if/else statement).
Bruce Young
@mutantspore
Apr 04 2016 08:05
@KortsF well it’s night time but fine and clear
so no sun
yes … lake, sun
KortsF
@KortsF
Apr 04 2016 08:06

Also I just realised that for a value of codIcon between 200 and 531, I should have written this with AND not OR, right?

else if (codIcon >= 200 || codIcon <= 531) {
        $("body").css("background-image", "url('https://dl.dropboxusercontent.com/u/22352213/2015_08_Life-of-Pix-free-stock-photos-plane-airport-rain-LEEROY_low.jpg')");

However, I made the change (to &&) and run the Pen again, and the image is still not changing.

Bruce Young
@mutantspore
Apr 04 2016 08:07
@KortsF yes I was about to say some of the ors need to be and
KortsF
@KortsF
Apr 04 2016 08:08
@mutantspore Yes, I didn't include different backgorund images for day and night. It's on my to-do list, but I wanted to move on to a different project.
Bruce Young
@mutantspore
Apr 04 2016 08:10
@KortsF
    // Cambio imagen de fondo según tiempo
      if (800 >= codIcon && codIcon <= 802) {
        $("body").css("background-image", "url('https://dl.dropboxusercontent.com/u/22352213/2016_01_Life-of-Pix-free-stock-photos-lake-nature-forest-LEEROY_low.jpg')");
      } else if (codIcon == 803 || codIcon == 804) {
        $("body").css("background-image", "url('https://dl.dropboxusercontent.com/u/22352213/clouds_A_Krivec_low.jpg')");
      } else if (codIcon >= 200 && codIcon <= 531) {
        $("body").css("background-image", "url('https://dl.dropboxusercontent.com/u/22352213/2015_08_Life-of-Pix-free-stock-photos-plane-airport-rain-LEEROY_low.jpg')");
      } else if (codIcon >= 600 && codIcon <= 622) {
        $("body").css("background-image", "url('https://dl.dropboxusercontent.com/u/22352213/2015_12_Life-of-Pix-free-stock-photos-mountains-snow-clouds-BlakeVerdoorn_low.jpg')");
      } else {
        $("body").css("background-image", "none");
      }
perhaps that might work
KortsF
@KortsF
Apr 04 2016 08:13
@mutantspore Yes, I was going to say I changed to AND all those statements where the comnparison operators were <= and >=. I just run it and it still doesn't work. I don't see what's wrong here.
Bruce Young
@mutantspore
Apr 04 2016 08:15
800 >= codIcon swap that around
codIcon >=800
KortsF
@KortsF
Apr 04 2016 08:18
@mutantspore That was it! Spot on! Is there a reason why? I thought the comparison should work irrespective of the order.
Bruce Young
@mutantspore
Apr 04 2016 08:19
well it would mean that it’s less than 800
KortsF
@KortsF
Apr 04 2016 08:19
@mutantspore Duh! Of course, silly me!! Thanks a lot, man!
CamperBot
@camperbot
Apr 04 2016 08:19
kortsf sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1358 | @mutantspore | http://www.freecodecamp.com/mutantspore
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 08:40
@mutantspore i adjusted my weatherapp but it still wont display to my body the background image
Robert Uivarosi
@URobert
Apr 04 2016 08:42
@Dueldrawer8 background: black; to your body in CSS
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 08:42
well i want it to display the backgrounds i specified in my object
Robert Uivarosi
@URobert
Apr 04 2016 08:44
@Dueldrawer8 sec
@Dueldrawer8 yeah, no wonder you have no background image. Have you checked the google dev console?
VM380 pen.js:29Uncaught TypeError: Cannot read property 'cond' of undefined$.ajax.success @ VM380 pen.js:29i @ jquery.min.js:2j.fireWith @ jquery.min.js:2z @ jquery.min.js:4(anonymous function) @ jquery.min.js:4
jquery.min.js:3GET http://s.codepen.io/boomerang/7c3e646c1d5030a46bc3fcb8ab51e6011459759513877/+%20pickURL%20+ 404 (Not Found)
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 08:47
i thought i specifed it
 $('body').css('background-image', 'url(" + pickURL + ")');
        var pickURL = weatherCond[data.weather[0].id].cond;
Bruce Young
@mutantspore
Apr 04 2016 08:48
@Dueldrawer8 you have a lot of quote marks in teh wrong place
Robert Uivarosi
@URobert
Apr 04 2016 08:48
        var pickURL = weatherCond[data.weather[0].id].cond;
        console.log(weatherOut)
Bruce Young
@mutantspore
Apr 04 2016 08:49
@Dueldrawer8 also where the url is used in the css assignment
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 08:49
so i need to take the quote marks out of my defined object that refers to my background images?
Robert Uivarosi
@URobert
Apr 04 2016 08:49
@Dueldrawer8 what @mutantspore said, you got to fix that. Second, your pickURL does not get assigned the right value... so there won't be a background image displayed anyway
Bruce Young
@mutantspore
Apr 04 2016 08:52
@Dueldrawer8 also the array of pictures is based on the weather icon, not the weather id
and you assign pickURL after you first use it
@Dueldrawer8 @Dueldrawer8
closer
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 08:57
wow when i console.log all my data values its not gettign anything
Jeff
@Jeffgl77
Apr 04 2016 08:58
need a bit of help to figure out why my fixed position footer doesn't span the full width of the screen like my fixed nav does. I appreciate any assistance with this. http://codepen.io/Jeffgl77/pen/zqEVMq?editors=1000
Bruce Young
@mutantspore
Apr 04 2016 08:59
@Dueldrawer8 @Dueldrawer8 well the fork I made of yours with som efixes seems to work now
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 09:00
ah there we go
about the icon
CamperBot
@camperbot
Apr 04 2016 09:00
you need to ask about @someone!
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 09:00
and yes the quotes
@mutantspore thanks!
CamperBot
@camperbot
Apr 04 2016 09:00
dueldrawer8 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1359 | @mutantspore | http://www.freecodecamp.com/mutantspore
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 09:03
how do i push the whole background down so the moon shows? i tried marin-top
margin-top.. just pushes my text down
Jeff
@Jeffgl77
Apr 04 2016 09:04
@Dueldrawer8 background-position
Randy Goldsmith
@Dueldrawer8
Apr 04 2016 09:06
@Jeffgl77 thanks..changed images on me lol i guess its misting now..
CamperBot
@camperbot
Apr 04 2016 09:06
dueldrawer8 sends brownie points to @jeffgl77 :sparkles: :thumbsup: :sparkles:
Islam Ibakaev
@dagman
Apr 04 2016 09:06
hey guys why just state doesn't get updated? http://codepen.io/dagman/pen/yOzemP?editors=0011
CamperBot
@camperbot
Apr 04 2016 09:06
:star: 131 | @jeffgl77 | http://www.freecodecamp.com/jeffgl77
prashant
@findname
Apr 04 2016 09:13
buttons are sticking on top in bootstrap can they be shifted a bit down http://codepen.io/findname/pen/qZPwWX?editors=1100 buttons are sticking on top
kirbyedy
@kirbyedy
Apr 04 2016 09:15
@findname padding-top
Bruce Young
@mutantspore
Apr 04 2016 09:15
@dagman i haven’t done react but I’ll just mention “asynchronous” and hope that helps
prashant
@findname
Apr 04 2016 09:17
to buttons
?
Jeff
@Jeffgl77
Apr 04 2016 09:17
has anybody gotten a chance to look at my issue? look at the bottom right. it doesn't go the full width.
kirbyedy
@kirbyedy
Apr 04 2016 09:18
@findname nav
or navbar, whatever you used
prashant
@findname
Apr 04 2016 09:19
<a href="" class="btn btn-lg btn-primary padding-top pull-right">Aboutme</a>
Bruce Young
@mutantspore
Apr 04 2016 09:20
@Jeffgl77 well i think there may be a few mismatched tags. seems to be an extra /div at the bottom, an /article with out a start
Shivam Arora
@shivamarora13
Apr 04 2016 09:27
I have pushed the JSON data I am getting from a API, in an array, making it a global array, still it doesn't show off outside the method
can anybody help?
Bruce Young
@mutantspore
Apr 04 2016 09:29
@shivamarora13 I guess you are trying to access it out side the getJSON ( or what ever you used). the API call is asynchronous so you’ll have make use of your returned data inside the getjson or in a function called from inside it
Jeff
@Jeffgl77
Apr 04 2016 09:31
@mutantspore I have now triple-checked the tag elements and they are all matched. I also removed the /article tag. still the issue remains. I know it is a css issue that I am overlooking.
Bruce Young
@mutantspore
Apr 04 2016 09:32
yes, i see a padding for the footer… all around and perhaps it needs to be in a container-fluid to get the full width
Jeff
@Jeffgl77
Apr 04 2016 09:35
@mutantspore thank you. fresh eyes is all it took.
CamperBot
@camperbot
Apr 04 2016 09:35
jeffgl77 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1360 | @mutantspore | http://www.freecodecamp.com/mutantspore
Bruce Young
@mutantspore
Apr 04 2016 09:36
@Jeffgl77 :)
Bruce Young
@mutantspore
Apr 04 2016 09:45
@shivamarora13 is there something we can look at?
JScapin
@JScapin
Apr 04 2016 10:08
Hello everybody ! I realy get stuck at the Wikipedia viewer challenge, I don't manage to understand, how to get the wiki data
Does someone already have finished and can explain me?
Stephen James
@sjames1958gm
Apr 04 2016 10:10
@JScapin I ended up using $.ajax rather than $.getJSON because of some issues. This is the command:
$.ajax('https://en.wikipedia.org/w/api.php?' +
    'action=query&list=search&srwhat=text&prop=links&format=json&callback=?&srsearch=' +
    search, {
      type: 'GET',
      contentType: 'application/json',
      dataType: 'json',
      success: function(response) {
This appears to be different than some others, the wikipedia API pages have more information about the options in the query string.
at the end of the URL is + search. search here is the string entered into the search box
JScapin
@JScapin
Apr 04 2016 10:13
@sjames1958gm thanks a lot, i already thought that ajax was a better way, so thanks for your confirmation. As a begginer, and as a french i have some trouble to understand eache url parameter like ?srwhat=text ...
CamperBot
@camperbot
Apr 04 2016 10:13
jscapin sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 422 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
JScapin
@JScapin
Apr 04 2016 10:13
&list...
and in your example you don't put a headers:{'API-User-Agent':'Example/10'}, like i have seen it in several example on the web
Stephen James
@sjames1958gm
Apr 04 2016 10:17
I don't know what that header is for.
JScapin
@JScapin
Apr 04 2016 10:17
The use of 'GET' do force us to use a form with method get ?
Stephen James
@sjames1958gm
Apr 04 2016 10:18
Yes
Md. Saadman Farhad
@saadmanfarhad
Apr 04 2016 10:19
can anyone help me with the logic of the intermediate algorithm Smallest Common Multiple. I seem to run into an infinite loop for some test cases.
JScapin
@JScapin
Apr 04 2016 10:19
so i cant build this app just using an input an a button?
Stephen James
@sjames1958gm
Apr 04 2016 10:19
Since you are retrieving information GET seems appropriate
@saadmanfarhad Sure -
Aexiron
@Aexiron
Apr 04 2016 10:20
hi guys! Beginner here, would love if anyone would comment on my first project >>> http://codepen.io/pen/LNOYdx
Stephen James
@sjames1958gm
Apr 04 2016 10:24
@Aexiron Looks pretty good - maybe some spacing after "Singapore's Founding Father" this should probably be a little larger as well. Links work well.
Aexiron
@Aexiron
Apr 04 2016 10:26
@sjames1958gm so i should add some bottom padding and make the font size slightly bigger?
Stephen James
@sjames1958gm
Apr 04 2016 10:26
@Aexiron In my opinion
Aexiron
@Aexiron
Apr 04 2016 10:27
okie lemme try
Stephen James
@sjames1958gm
Apr 04 2016 10:28
@JScapin https://www.mediawiki.org/wiki/API:Search this page describes the parameters. Maybe can be presented in French. The fields starting with "sr" are for searching srsearch means search all page titles and content
Md. Saadman Farhad
@saadmanfarhad
Apr 04 2016 10:31
can anyone help me with the logic of the intermediate algorithm Smallest Common Multiple ?? I seem to run into an infinite loop for some test cases !!
Stephen James
@sjames1958gm
Apr 04 2016 10:31
@saadmanfarhad Post it
If you are having infinite loop search for code path that does not increment or decrement your loop variable.
Md. Saadman Farhad
@saadmanfarhad
Apr 04 2016 10:32
function smallestCommons(arr) {
  var ar1=[];
  var ar2=[];
  var mul1;
  var mul2;
  var count;
  var scm;
  if(arr[1]<arr[0]){
    var s= arr[1];
    arr[1]=arr[0];
    arr[0]=s;
  }
  for(var i=1;;i++){
    mul1=arr[0]*i;
    mul2=arr[1]*i;
    ar1.push(mul1);
    ar2.push(mul2);
    for(var j=0;j<ar1.length;j++){
      count=0;
      for(var k=0;k<ar2.length;k++){
        if(ar1[j]===ar2[k]){
          for(var l=arr[0]+1;l<arr[1];l++){
            if (ar1[j]%l===0){
              count++;
            }
          }
        }
        if(count===(arr[1]-arr[0]-1)){
          return ar1[j];
        }
      }
    }
  }
}


smallestCommons([1,13]);
Stephen James
@sjames1958gm
Apr 04 2016 10:33
can you edit to put ``` at beginning and end?
function smallestCommons(arr) {
  var ar1=[];
  var ar2=[];
  var mul1;
  var mul2;
  var count;
  var scm;
  if(arr[1]<arr[0]){
    var s= arr[1];
    arr[1]=arr[0];
    arr[0]=s;
  }
  for(var i=1;;i++){
    mul1=arr[0]*i;
    mul2=arr[1]*i;
    ar1.push(mul1);
    ar2.push(mul2);
    for(var j=0;j<ar1.length;j++){
      count=0;
      for(var k=0;k<ar2.length;k++){
        if(ar1[j]===ar2[k]){
          for(var l=arr[0]+1;l<arr[1];l++){
            if (ar1[j]%l===0){
              count++;
            }
          }
        }
        if(count===(arr[1]-arr[0]-1)){
          return ar1[j];
        }
      }
    }
  }
}


smallestCommons([1,13]);
Stephen James
@sjames1958gm
Apr 04 2016 10:41
@sjames1958gm Really hard to tell what is going on with 4 nested for loops. Maybe break out the inside stuff to a function. With no exit test in the first for loop and the final count === the only way out it is not surprising that you have an infinite loop.
Md. Saadman Farhad
@saadmanfarhad
Apr 04 2016 10:43
ok I will break it into a function
Stephen James
@sjames1958gm
Apr 04 2016 10:45
@sjames1958gm Make sure the function has a clear purpose, such as finding the least common multiple of two numbers, then you can iteratively apply that to the whole range.
Md. Saadman Farhad
@saadmanfarhad
Apr 04 2016 11:06
right
96street
@96street
Apr 04 2016 11:26
I can't get the text (<p>) to float to the right of the picture http://codepen.io/anon/pen/YqEPXL
i've put height 100% on the picture so not sure why it takes up less
Matt Singleton
@mattjsingleton
Apr 04 2016 11:37
Is anyone able to help me with a work project? I’m trying to extract the text between every <b> tag and it’s closing tag, to a text file/csv
Manpreet Singh
@designviacode
Apr 04 2016 11:45
Hey Matt.. I can help
I did something like this for anchor tags recently..
Give me a minute I'll share the code to you.
Matt Singleton
@mattjsingleton
Apr 04 2016 11:51
Great, thanks
Manpreet Singh
@designviacode
Apr 04 2016 12:14
var dummy = {
  text: '<a href="" class="item">Hello, how are you ?</a>',
  init: function() {
    console.clear();
    this.stripA();
    this.log();
    this.render();
  },
  stripA: function() {
    this.result = this.text.match(/<[a][^>]*>(.+?)<\/[a]>/, '');
    this.render();
    return this.result;
  },
  render: function() {
    document.body.innerHTML = this.text;
  },
  log: function() {
    console.log(this.stripA()[1]);
  }
};
dummy.init();
@mattjsingleton here you go.
Matt Singleton
@mattjsingleton
Apr 04 2016 12:21
Javascript, I’m assuming?
thanks @designviacode
CamperBot
@camperbot
Apr 04 2016 12:22
mattjsingleton sends brownie points to @designviacode :sparkles: :thumbsup: :sparkles:
:star: 186 | @designviacode | http://www.freecodecamp.com/designviacode
Matt Singleton
@mattjsingleton
Apr 04 2016 12:24
actually, I don’t recognise some of the syntax
dave oh
@david-oh-git
Apr 04 2016 12:29
hello goodday
i am having issues with the calculator zipline, what html element do i use as the calculator display.
Michael de Lima Alves
@elderalves
Apr 04 2016 12:41

What do you think about my Wikipedia App?

http://codepen.io/MichaelAlves/full/zqEeLb/

Manpreet Singh
@designviacode
Apr 04 2016 12:44
@mattjsingleton yeah its js .. just replace '[a]' with the tag you want to change with, in your case .. b or bold tag :smile:
96street
@96street
Apr 04 2016 12:44
<div class="informs">
    <div class="inform">
            <img src="#">

        <h5>28</h5>
        <h5>29</h5>
        <h5>30</h5>
        <h5>31</h5>
        <h5>32</h5>
        <h5>33</h5>

        <br><br><br>
        <h3>QQQQ</h3>
    </div>
</div>
.inform h5 {
    display: inline-block;
    margin-right: 45px;
    font-weight: 900;
}

.informs .inform h5:last-child {
    margin-right: 10px;
}
why isn't last-child working here?
Stephen James
@sjames1958gm
Apr 04 2016 12:45
@hirako-shinji I started with <input> but that allowed the user to edit. Using <p> with appropriate css should work
Manpreet Singh
@designviacode
Apr 04 2016 12:47
@96street what are you trying to do .. could you explain a bit .. ?
96street
@96street
Apr 04 2016 12:49
give the last h5 margin-right of 10px instead of 45px
@designviacode
Manpreet Singh
@designviacode
Apr 04 2016 13:25
@96street somehow it just doesn't work ..
really wierd issue..
@96street but it works if you set an id to the last element .. like such :
.informs .inform h5#last {
  margin-right: 10px;
}
Eric Murta
@murtinha
Apr 04 2016 13:45

@murtinha

function smallestCommons(arr) {
  var check=0;
  var x=0;
  var value=Math.max(arr[0],arr[1]);
  var maxval=Math.max(arr[0],arr[1]);
  var cond=(Math.max(arr[0],arr[1])-(Math.min(arr[0],arr[1])))+1;

  while(x===0){
      check=0; 
    for(i=Math.min(arr[0],arr[1]);i<=maxval;i++){
      if((value%i)===0){
        check++;

      }
    }

    if(check==cond){
      x=1;       
    }
    else{
      value++;
    }

    }

  return value;
}


smallestCommons([1,12]);

Guys, on challenge smalest common multiple, my logic is working fine for number untill 12, if a put 13 there my loop becomes infinite...

Rich Keyzor
@Web-Dev-Rich
Apr 04 2016 13:53
This message was deleted
nsloc22
@nsloc22
Apr 04 2016 14:18
@murtinha run your code with [1,13] as parameter in chrome console and it gave correct answer
no infinite loop
but it took more time then with [1,12] to run it
try with //noprotect
Stephen James
@sjames1958gm
Apr 04 2016 14:35
@murtinha Since 13 is prime it will have to run 13! times through the loop
Sephem
@Sephem
Apr 04 2016 15:06
Allwikipedias api options make it so complicated to use and their documentation is too complex to get started. Is there a dummies article for wikipedia api, like something that shocases a few of the most common options and actions?
Eric Murta
@murtinha
Apr 04 2016 15:09
@nsloc22 what do you mean by noprotect?
Ademola Adegbuyi
@ooade
Apr 04 2016 15:11
@murtinha //noprotect makes sure that your looped values are not cut out
Eric Murta
@murtinha
Apr 04 2016 15:15
@marhyorh where should I put that?
Ademola Adegbuyi
@ooade
Apr 04 2016 15:15
@murtinha at the top, before your code
Eric Murta
@murtinha
Apr 04 2016 15:18
@marhyorh WOW it worked hahahaha @sjames1958gm . But I still didnt understand... is that a bug on freecodecamp?
nsloc22
@nsloc22
Apr 04 2016 15:19
@murtinha if you your code takes to much time to run I guess it thinks it's
infinite loop
Nenba Jonathan
@nejostar
Apr 04 2016 15:20
hello world
CamperBot
@camperbot
Apr 04 2016 15:20

welcome to FreeCodeCamp @nejostar!

Eric Murta
@murtinha
Apr 04 2016 15:21
@nsloc22 omg hahahah thanks guys! @marhyorh
CamperBot
@camperbot
Apr 04 2016 15:21
murtinha sends brownie points to @nsloc22 and @marhyorh :sparkles: :thumbsup: :sparkles:
:star: 646 | @marhyorh | http://www.freecodecamp.com/marhyorh
api offline
narkeeta
@narkeeta
Apr 04 2016 15:25

hey guys, so when I write the if statements in this code it brakes my game so that it wont light up the sequences, does someone know how to fix this?

function lightup(tile) {
    //plays sound for tile that lights up
    if (tile == "#0") sound0.play();
    if (tile == "#1") sound1.play();
    if (tile == "#2") sound2.play();
    if (tile == "#3") sound3.play();
    //sets tile opacity to 1
    $(tile).addClass('lit');
    //sets tile opacity back to .6
    window.setTimeout(function() {
      $(tile).removeClass('lit');
    }, 300);

  }

http://codepen.io/narkeeta/pen/MyYyra?editors=0010

nsloc22
@nsloc22
Apr 04 2016 15:30
@narkeeta getting an error bootstrap requires jquery I don't know if it's true but I think you need to add jquery before you add bootstrap in codepen settings
narkeeta
@narkeeta
Apr 04 2016 15:30
okay Ill try that
The code is still broken if I swap those
nsloc22
@nsloc22
Apr 04 2016 15:31
yeah but no error now
narkeeta
@narkeeta
Apr 04 2016 15:31
It works perfectly if I remove the .play() if statement so I'm not sure what error is occuring
true thanks @nsloc22
CamperBot
@camperbot
Apr 04 2016 15:32
narkeeta sends brownie points to @nsloc22 :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Apr 04 2016 15:32
@narkeeta With no sound? it works?
CamperBot
@camperbot
Apr 04 2016 15:32
:star: 331 | @nsloc22 | http://www.freecodecamp.com/nsloc22
narkeeta
@narkeeta
Apr 04 2016 15:33
yeah with no sounds
For some reason the if statements stall the code out when it gets to them
Stephen James
@sjames1958gm
Apr 04 2016 15:37
@narkeeta Is the error only the first time they play (maybe there is loading delay) just guessing.
narkeeta
@narkeeta
Apr 04 2016 15:38
no if the player hits the right button and it goes to play the second sequence of lights it still doesn't show the sequence
Lanitta
@DivaWeb
Apr 04 2016 15:38
Hello Campers!!!
I am very frustrated with some of these lessons because I read them over and over again follow the example they provide and they don't work.
Stephen James
@sjames1958gm
Apr 04 2016 15:40
@DivaWeb I have to admit the description of the problems are suspect on many of them.
Lanitta
@DivaWeb
Apr 04 2016 15:40
Can someone help me out that has made it through "Make Object Properties Private" so I can see what they are trying to tell me what to do
@sjames1958gm yes very
Robert Crawford
@RobertCC18
Apr 04 2016 15:42
@DivaWeb what seems to be the trouble?
can you post you code?
Lanitta
@DivaWeb
Apr 04 2016 15:42
@RobertCC18 lol if I knew I could do it lol
Stephen James
@sjames1958gm
Apr 04 2016 15:43
@DivaWeb They are asking you to add similar var and functions to bike, like in car above for gear as opposed to speed..
Lanitta
@DivaWeb
Apr 04 2016 15:43

@RobertCC18 var Bike = function() {

// Only change code below this line.
var gear;

this.getGear = function(change){
gear += change;
};

this.setGear = function(){
return gear;
};
};

var myCar = new Car();
var myBike = new Bike();

Stephen James
@sjames1958gm
Apr 04 2016 15:43
@DivaWeb Try swapping the names.
@DivaWeb get should return the gear and set should, well, set the gear
Lanitta
@DivaWeb
Apr 04 2016 15:44
@sjames1958gm hmmmm swapping the names?
narkeeta
@narkeeta
Apr 04 2016 15:44
solved my problem if anyone was still figuring it out
Lanitta
@DivaWeb
Apr 04 2016 15:44
@sjames1958gm I understand what it is suppose to do and I follow their example and I get nothing lol
Stephen James
@sjames1958gm
Apr 04 2016 15:45
@DivaWeb swap the names getGear and setGear
Lanitta
@DivaWeb
Apr 04 2016 15:45
@sjames1958gm ok I will try that however let me state that their instructions do not have them listed that way
Stephen James
@sjames1958gm
Apr 04 2016 15:46
"myBike.getGear() should return 3"
Lanitta
@DivaWeb
Apr 04 2016 15:46
@sjames1958gm did not work
Stephen James
@sjames1958gm
Apr 04 2016 15:47
@DivaWeb One more change - set the gear don't += the gear
Steven Gallegos
@webdev1990
Apr 04 2016 15:47
Has anyone completed the website portfolio project?
Lanitta
@DivaWeb
Apr 04 2016 15:47
@sjames1958gm grrrrrr i just got it to work by switching the name and and making gear =
@mrstevengallegos yes
Steven Gallegos
@webdev1990
Apr 04 2016 15:48
Did you find a template online, use snippets, or did you build everything yourself?
Here is a link to my port website right now: webdev1990. com
I can't seem to make it beautiful lol
Lanitta
@DivaWeb
Apr 04 2016 15:49
@mrstevengallegos I did it all myself
Robert Crawford
@RobertCC18
Apr 04 2016 15:49
@DivaWeb glad to see you made it through
Steven Gallegos
@webdev1990
Apr 04 2016 15:49
Thanks!
Lanitta
@DivaWeb
Apr 04 2016 15:50
@sjames1958gm @RobertCC18 here are the instructions : Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
they show them going the other way than the way they are suppose to grrr
@mrstevengallegos when you are first starting don't worry about making beautiful, focus on what you would like to do and how you are going to get there. Once you get past the technical stuff you can then work on making it pretty
Steven Gallegos
@webdev1990
Apr 04 2016 15:53
I see
So far, it's plain old HTML with a little bit of CSS, is that okay for the project?
Will there be more to add later?
Thanks!!
Lanitta
@DivaWeb
Apr 04 2016 15:55
@mrstevengallegos they want you to use bootstrap to make a single scrolling page to make your portfolio page
@sjames1958gm @RobertCC18 thanks guys
CamperBot
@camperbot
Apr 04 2016 15:56
divaweb sends brownie points to @sjames1958gm and @robertcc18 :sparkles: :thumbsup: :sparkles:
:star: 242 | @robertcc18 | http://www.freecodecamp.com/robertcc18
:star: 425 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Steven Gallegos
@webdev1990
Apr 04 2016 15:59
I see. So, essentially, simple design with what they are asking for, nothing too advanced?
Stephen James
@sjames1958gm
Apr 04 2016 16:00
@mrstevengallegos Start simple and build from there or you will get frustrated. Get a framework working and you can go from there.
Jacob Sommerville
@JellyKid
Apr 04 2016 16:00
@mrstevengallegos I've waited till the end to even make my portfolio. IDK why they have you make it in the beginning with no content to put in it. Also, it's your port, so whatever design choices you think express yourself the best and show off your talent is what I would go for.
Lanitta
@DivaWeb
Apr 04 2016 16:00
@mrstevengallegos yeah if you look up the term spyscroll with bootstrap you should find all the info you need. You should take a look at the example they provide to give you an idea what they are expecting
@JellyKid It is to get your feet wet with bootstrap and you can add and change things as you learn them
Steven Gallegos
@webdev1990
Apr 04 2016 16:01
Thanks guys very helpful!!!
Jacob Sommerville
@JellyKid
Apr 04 2016 16:01
I would say bootstrap is more of a crutch. Learn how to use flexboxes and jquery up your own nav, but that's just IMHO.
Lanitta
@DivaWeb
Apr 04 2016 16:02
@JellyKid as programmers everyone has their own style and it is great that you are creating your own style however in today's market they are looking for people who know bootstrap a well as jquery
Robert Crawford
@RobertCC18
Apr 04 2016 16:09
I need a little help with the tic tack toe game challenge, I have my board and my squares are clickable, where do i go next with the javascript? I need a nudge in the right direction
Jacob Sommerville
@JellyKid
Apr 04 2016 16:09
@DivaWeb Bootstrap is just boilerplate. I'm saying if you want to really become a frontend dev, learn how bootstrap is doing the things it's doing, then use bootstrap to put things together if need be. It is a nice framework to work around, but what if you don't like how something is formated in bootstrap or you need a more custom solution for a something. You're going to be SOL if you don't know the CSS/JS behind bootstrap.
@RobertCC18 https://codepen.io/JellyKid/pen/bpoYdK
My functions are pretty self explanatory. Take a look at the $(document).ready(... to get an idea of how the game flows.
Stephen James
@sjames1958gm
Apr 04 2016 16:10
@RobertCC18 You are going to store the current board state, so you know what are the valid next moves and then code up how to know when there is a win or not
Robert Crawford
@RobertCC18
Apr 04 2016 16:14
ok, I am kinda lost, where do i start?
Stephen James
@sjames1958gm
Apr 04 2016 16:15
@RobertCC18 I am just working on this I started with how to store the board (3x3 array). Then wrote code to figure out how to determine if a board state was win for X, for O, a draw or nothing
Jacob Sommerville
@JellyKid
Apr 04 2016 16:16
@RobertCC18 Just getting a couple of the game functions down. Like @sjames1958gm said, storing the current state of the board, updating the display to reflect what's stored on the board, allowing the player to be able to play a peice, being able to test for a win or a cats game. All of those are functions of the game that you can work on and then test.
I would first figure out how you are going to store the state of the board. I'm using a JS object that every square has a letter assigned to it.
The 3x3 array is a good approach as well.
Jeff
@adzam5
Apr 04 2016 16:18
Anyone complete the "Convert HTML Entities" challenge? I just completed it pretty easily, but I feel like my code is way bulkier than it needs to be
Jacob Sommerville
@JellyKid
Apr 04 2016 16:20
@RobertCC18 The first thing I did was make sure that when a tile on the board was clicked, whatever piece the player was would go into the board in the browser and go into the data representing the board(var board). Does that make sense?
Robert Crawford
@RobertCC18
Apr 04 2016 16:21
yes
John Liddel
@BreakingOceans
Apr 04 2016 16:22

Why does this image not become responsive?

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>

<style>
.container-fluid {}
</style>

<div class="container-fluid">

<img src="http://images2.fanpop.com/image/photos/9800000/Great-Mountains-mountains-and-waterfalls-9841962-1920-1440.jpg">

</div>

Hm, how do I post code windows like the other people?
Jeff
@adzam5
Apr 04 2016 16:23
@BreakingOceans put the code between three backticks ```
nhidev
@nhidev
Apr 04 2016 16:24
@BreakingOceans add class img-responsive to image
John Liddel
@BreakingOceans
Apr 04 2016 16:24
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>

<style>
.container-fluid {}
</style>

<div class="container-fluid">

  <img src="http://images2.fanpop.com/image/photos/9800000/Great-Mountains-mountains-and-waterfalls-9841962-1920-1440.jpg">

</div>
@adzam5 Thank you!
CamperBot
@camperbot
Apr 04 2016 16:25
breakingoceans sends brownie points to @adzam5 :sparkles: :thumbsup: :sparkles:
John Liddel
@BreakingOceans
Apr 04 2016 16:25
@nhidev Thanks a mill! I just assumed that the class "container-fluid" makes everything responsive in that tag.
CamperBot
@camperbot
Apr 04 2016 16:25
breakingoceans sends brownie points to @nhidev :sparkles: :thumbsup: :sparkles:
:star: 385 | @adzam5 | http://www.freecodecamp.com/adzam5
:star: 283 | @nhidev | http://www.freecodecamp.com/nhidev
John Liddel
@BreakingOceans
Apr 04 2016 16:27
So the class "container-fluid" made everything responsive within the Div tag in the FCC exercise, so why doesn't it work in my code above? Why do I have to the class "img-responsive" to the image as well?
(Very new here, still trying to figure out how to even chat.)
Shreyas Amrutkar
@shreyasamrutkar
Apr 04 2016 16:29
@BreakingOceans container fluid makes the div responsive not its image elements... that is during resizing div will resize perfectly but not the contents such as images
@BreakingOceans so we have to add img-responsive tag IMO
John Liddel
@BreakingOceans
Apr 04 2016 16:29
@shreyasamrutkar Ah thanks so much, that helps immensely. I was so confused!
CamperBot
@camperbot
Apr 04 2016 16:29
breakingoceans sends brownie points to @shreyasamrutkar :sparkles: :thumbsup: :sparkles:
:star: 155 | @shreyasamrutkar | http://www.freecodecamp.com/shreyasamrutkar
Angelos Spyratos
@spyratos
Apr 04 2016 16:33
hello guys !
I need some help with my portfolio pen
Lanitta
@DivaWeb
Apr 04 2016 16:34
@spyratos what is the problem?
Robert Crawford
@RobertCC18
Apr 04 2016 16:34
@spyratos ok, whats the problem?
Angelos Spyratos
@spyratos
Apr 04 2016 16:34
i have set each section height to 100vh so that it is going to take the whole screen when somebody visits it but i would like a more complex behaviour
like having this as the default but increase the size of a section when there is more content than what fits inside the section
is this possible ?
by css alone ? should i use jquery or js ? any suggestions?
Lanitta
@DivaWeb
Apr 04 2016 16:36
@spyratos so it is great you have the vh figured out but what about the with of the screen?
Angelos Spyratos
@spyratos
Apr 04 2016 16:36
(also i want the heart in the navbar to be always in the middle but i ll figure something :P untill now lets say it works in a way )
@DivaWeb its automated from the bootstrap as i use its row and col-xs classes
Shreyas Amrutkar
@shreyasamrutkar
Apr 04 2016 16:36
@spyratos can you try min-height css parameter and sets it's value to 100vh
Angelos Spyratos
@spyratos
Apr 04 2016 16:37
@shreyasamrutkar and how am i going to change the max-height according to the content ?
Lanitta
@DivaWeb
Apr 04 2016 16:37
@spyratos well your project doesn't take up the whole page width
Angelos Spyratos
@spyratos
Apr 04 2016 16:38
@DivaWeb but i dont want it to :P i want 10 out of 12 columns and the left and right free space
@DivaWeb i dont know if it is a good design policy but i seem to like it :P
Lanitta
@DivaWeb
Apr 04 2016 16:39
@spyratos but when you make it smaller it will not fill the whole screen and doesn't allow your viewers the ease of seeing it
Shreyas Amrutkar
@shreyasamrutkar
Apr 04 2016 16:40
@spyratos height will increase automatically from 100vh once more content becomes available
Angelos Spyratos
@spyratos
Apr 04 2016 16:40
@DivaWeb hmmm thats a good point i ll change it to cover the whole screen ... thanks for noticing but still i do not know what to do with the max height
CamperBot
@camperbot
Apr 04 2016 16:40
spyratos sends brownie points to @divaweb :sparkles: :thumbsup: :sparkles:
:star: 284 | @divaweb | http://www.freecodecamp.com/divaweb
Angelos Spyratos
@spyratos
Apr 04 2016 16:40
@shreyasamrutkar just by assigning a min-height ?
Mahak Narayan Singh
@makkBit
Apr 04 2016 16:40
I'm not able to figure out Wikipedia's API . Can someone please recommend me something, that would help me out?
Lanitta
@DivaWeb
Apr 04 2016 16:41
@spyratos you also want your content to stay with in your sections which it does not do when the screen is made smaller
Shreyas Amrutkar
@shreyasamrutkar
Apr 04 2016 16:41
@spyratos yes..i tried your codepe...i say it works..give it a shot
Angelos Spyratos
@spyratos
Apr 04 2016 16:42
@shreyasamrutkar thanks a lot my friend! i ll give it a try!
CamperBot
@camperbot
Apr 04 2016 16:42
spyratos sends brownie points to @shreyasamrutkar :sparkles: :thumbsup: :sparkles:
:star: 156 | @shreyasamrutkar | http://www.freecodecamp.com/shreyasamrutkar
Angelos Spyratos
@spyratos
Apr 04 2016 16:42
@DivaWeb thats what i asked for :P ! how to keep the content inside each section by changing the height of the section
@shreyasamrutkar that worked great! thanks aggain !
CamperBot
@camperbot
Apr 04 2016 16:44
spyratos sends brownie points to @shreyasamrutkar :sparkles: :thumbsup: :sparkles:
:warning: spyratos already gave shreyasamrutkar points
Lanitta
@DivaWeb
Apr 04 2016 16:45
@spyratos what is the reason you have seperate dives with different col sizes in your html code just before your section 1
Shreyas Amrutkar
@shreyasamrutkar
Apr 04 2016 16:46
@spyratos you are welcome :thumbsup:
Angelos Spyratos
@spyratos
Apr 04 2016 16:47
@DivaWeb i change it already.... i had a blank div of col-xs-1 in order to leave the left column blank i just remove it and changed the main div to col-xs-12 and now its good
Lanitta
@DivaWeb
Apr 04 2016 16:50

@spyratos so here is what I found worked for mine specially when I started working with background photos.#par1{
background-image: url("http://i410.photobucket.com/albums/pp189/azqtpie/pillars_zpsz1tovmst.jpg");
background-size:100% 100%;
background-attachment:fixed;

height: 100vh;

font-size:20px; position:relative;

Angelos Spyratos
@spyratos
Apr 04 2016 16:52
@DivaWeb thank you for the suggestion but i think i ll keep it simple when it comes to the background as i dont actually like sites with heavy backgrounds . Anyway i ll keep in mind the option of setting a photo as the background still thanks a lot ! i appriciate it !
CamperBot
@camperbot
Apr 04 2016 16:52
spyratos sends brownie points to @divaweb :sparkles: :thumbsup: :sparkles:
:warning: spyratos already gave divaweb points
Lanitta
@DivaWeb
Apr 04 2016 16:53
@spyratos you don't have to use it only for pics you can use it for a color background as well
Walter
@relwiwa
Apr 04 2016 17:01
Hi there, I am having trouble with the Simon Game challenge. I try to play multiple audio files one after the other, and it works on Desktop, but it does not seem to work on mobile devices. Instead of playing the four sounds, only two get played, sometimes less, sometimes more. I don't get what the problem is. I setup a Codepen, and would appreciate any ideas. I came across the Web Audio API, but is it really necessary to use it? Here's the codepen: http://codepen.io/relwiwa/pen/WwXrRe Thank you guys :-)
Christopher Wiles
@ChrisWiles
Apr 04 2016 17:04
@relwiwa I didn't use web audio api on mine but runs really slugish on mobile tho. Desktop seems fine
Walter
@relwiwa
Apr 04 2016 17:09
Hey @ChrisWiles The example by FreeCodeCamp seems to work fine as far as the sounds are concerned, so I wanted mine to work alright on mobile as well, or at least understand what's wrong ;-) You have any idea?
Slusherman
@Slusherman
Apr 04 2016 17:58
Having some trouble with converting html tags with RegEx, am I on the right track?
function convert(str) {
  // &colon;&rpar;
  var amp = new RegExp('&', 'i');
  var lt = new RegExp("<");
  var gt = new RegExp('>', 'i');
  var q = new RegExp('\'', 'i');
  var dq = new RegExp('"', 'i');
  var newstr;

  if(amp.test(str)){
      newstr = str.replace(amp, "&amp;");
      return newstr;
  } else if (lt.test(str)) {
   newstr = str.replace(lt, "&lt;");
      return newstr;
  } else if (gt.test(str)) {
    newstr = str.replace(gt, "&gt;");
      return newstr;
  } else if (q.test(str)) {
  newstr = str.replace(q, "&apos;");
      return newstr;
  } else if (dq.test(str)) {
   newstr = str.replace(dq, "&quot;");
      return newstr;
  } else {
    return str;
  }

}

convert("Hamburgers < Pizza < Tacos");
Stephen James
@sjames1958gm
Apr 04 2016 18:00
@Slusherman You need global replace to change more than one instance. Also what if there were both a & and a < ?
Slusherman
@Slusherman
Apr 04 2016 18:01
@sjames1958gm ah thanks! forgot about that global option
CamperBot
@camperbot
Apr 04 2016 18:01
slusherman sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 431 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Jeff
@adzam5
Apr 04 2016 18:03
I seem to have created an infinite loop on a FCC challenge. Every time I go back to the page it locks up without me doing anything. I tried clearing my cache, but that didn't help. Any suggestions?
Stephen James
@sjames1958gm
Apr 04 2016 18:10
@adzam5 From the issue on github - Workaround: clearing browser cookies may clear the user-entered code. On Chrome I wiped my browser history and I could then refresh the page without my old code showing up. - I think all of your old solutions will go as well
Nathan
@natertot12
Apr 04 2016 18:16
@adzam5 I've done the same thing, I either used incognito or a different browser
Stephen James
@sjames1958gm
Apr 04 2016 18:17
FreeCodeCamp/FreeCodeCamp#2286
Jeff
@adzam5
Apr 04 2016 18:17
@sjames1958gm Thanks! Clearing history in Chrome worked
CamperBot
@camperbot
Apr 04 2016 18:17
adzam5 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 432 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Juwdohr
@Juwdohr
Apr 04 2016 19:13
good morning all
Lanitta
@DivaWeb
Apr 04 2016 19:14
good afternoon :smile : )
Luis Parra
@leparrav
Apr 04 2016 19:16
Hello all :)
A review of my latest zipline would be fine thanks : )
Ivan
@elementWebDev
Apr 04 2016 19:17
i need some help with the navbar hamburgur menu
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <a href="http://codepen.io/fu11st4ck/" class="navbar-brand" target="_blank">Ivan Huddleston</a>
    </div>
    <!-- <span class="glyphicon glyphicon-menu-hamburger"></span> -->
    <div class="collapse navbar-collapse">
      <ul class="nav navbar-nav navbar-right">
        <li class="active"><a href="#about">About</a></li>
        <li><a href="#portfolio">Portfolio</a></li>
        <li><a href="#contact">Contact</li>              
      </ul>
    </div>
  </div>
</nav>
Lanitta
@DivaWeb
Apr 04 2016 19:19
@oghosting what is your problem?
Ivan
@elementWebDev
Apr 04 2016 19:19
how do I include the menu icon and have the menu show when clicked
*show under
Lanitta
@DivaWeb
Apr 04 2016 19:21
@oghosting why do you have the glyph commented out?
Ivan
@elementWebDev
Apr 04 2016 19:22
because the menu wasn't working under it
Lanitta
@DivaWeb
Apr 04 2016 19:22
@oghosting so which link are you wanting the glyph to be on?
Ivan
@elementWebDev
Apr 04 2016 19:24
the whole nav I guess... i've never used it before
i tried to put the span around the entire ul bu it didn't work
Stephen James
@sjames1958gm
Apr 04 2016 19:25
:zzz:
Lanitta
@DivaWeb
Apr 04 2016 19:26
Oh ok so you want it on you nav bar like a logo
Ivan
@elementWebDev
Apr 04 2016 19:27
yes.. on the right
Lanitta
@DivaWeb
Apr 04 2016 19:29
so you will want to use brand image from the nav bar section in bootstrap
@oghosting Here is the link http://getbootstrap.com/components/#navbar
James Bond
@Dman89
Apr 04 2016 19:30
my code is waiting for the var to compute
function randomize() {    
    var random = Math.floor(Math.random() * open.length);
  temp = open.splice(random, 1);
  var num = board.indexOf(temp);
   document.getElementById(temp).innerHTML = num;
};
or temp is not working in the num var
Lanitta
@DivaWeb
Apr 04 2016 19:32
hmmmm is anyone else having problems with free code camps web site? I keep getting the message the site is off line
James Bond
@Dman89
Apr 04 2016 19:32
normal during the day, it will load in a sec just retry
board = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
open = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
function randomize() {    
    var random = Math.floor(Math.random() * open.length);
  temp = open.splice(random, 1);
  num = board.indexOf(temp)
   document.getElementById(temp).innerHTML = num;
};
Michael Daryl Mayo
@chromity
Apr 04 2016 19:48
can someone help me with this, http://codepen.io/chromity/pen/NNwWoJ. my site is not that mobile responsive. can someone guide me on what to do. thanks!
the doer
@ewathedoer
Apr 04 2016 19:51

I have just finished my Weather App, and before submitting I am looking for some suggestions, Here is debug mode: http://s.codepen.io/thedoer/debug/vGeYZp
and here the editor’s view: http://codepen.io/thedoer/pen/vGeYZp

I still have some display problems on mobile Safari, any idea why mobile Safari on iPad calculates vindows hight differently?

Jeff
@adzam5
Apr 04 2016 19:54
@ewathedoer Looks good!
Stephen James
@sjames1958gm
Apr 04 2016 19:54
@ewathedoer Love the styling, not sure about the F/C slider way over in the top left.
Jeff
@adzam5
Apr 04 2016 19:55
@ewathedoer I am not sure if this is causing your issues on an iPad, but I have noticed that iOS devices do not render properly when you have html, head, and/or body tags in the HTML section of CodePen.
the doer
@ewathedoer
Apr 04 2016 19:56
@sjames1958gm I will sleep it over
@adzam5 where do you put the info from head then?
Do you omit it at all?
and only put for production?
Stephen James
@sjames1958gm
Apr 04 2016 19:57
@ewathedoer Its super cute.
Jeff
@adzam5
Apr 04 2016 19:58
@ewathedoer If you click on the settings for the HTML section there is a section that allows you to add stuff to the head
the doer
@ewathedoer
Apr 04 2016 19:58
@sjames1958gm yeah the graphics are just a bit customaized but the cuteness is from Freepik resources
@adzam5 so you take it out from html and add in settings, all of them from current head, right?
Jeff
@adzam5
Apr 04 2016 20:02
@ewathedoer Yes. Although it is not necessary to add head information in CodePen.
the doer
@ewathedoer
Apr 04 2016 20:02
thanks @adzam5 I will play with it
CamperBot
@camperbot
Apr 04 2016 20:02
ewathedoer sends brownie points to @adzam5 :sparkles: :thumbsup: :sparkles:
:star: 388 | @adzam5 | http://www.freecodecamp.com/adzam5
Jeff
@adzam5
Apr 04 2016 20:03
@ewathedoer No problem
Juwdohr
@Juwdohr
Apr 04 2016 20:30
Hey trying to get my online button to work any help?
http://codepen.io/Jarvis-327/pen/BKWvYw?editors=1010
Robert Crawford
@RobertCC18
Apr 04 2016 20:31

I want to show a brower popup that chooses X or O in a tic tac toe game '''
var y=window.prompt("please choose your weapon")
window.alert(y)

if (var y === X) {
$(document).ready(function() {
$("#sq1").on("click", function(){
// Only change code below this line.
$(".message").html("X");
// Only change code above this line.
});
});

}

else {
$(document).ready(function() {
$("#sq1").on("click", function(){
// Only change code below this line.
$(".message").html("O");
// Only change code above this line.
});
});

} '''

CamperBot
@camperbot
Apr 04 2016 20:31
:bulb: to format code use backticks! ``` more info
Michael Karpinski
@karpimpski
Apr 04 2016 20:31
if I'm making a canvas, would writing code like this:
setInterval(drawEverything, 1000/60)
be 60 FPS?
Robert Crawford
@RobertCC18
Apr 04 2016 20:32
var y=window.prompt("please choose your weapon")
window.alert(y)

if (var y === X) {
  $(document).ready(function() {
    $("#sq1").on("click", function(){
      // Only change code below this line.
      $(".message").html("X");
      // Only change code above this line.
    });
  });

}

else {
  $(document).ready(function() {
    $("#sq1").on("click", function(){
      // Only change code below this line.
      $(".message").html("O");
      // Only change code above this line.
    });
  });

}
What am i doing wrong?
ok, i am just goig to try a diffrent approach
Dardan Demiri
@dardandemiri
Apr 04 2016 20:38
Is here anyone who knows what Erros mean
because I don't know what this means:
extensions::uncaught_exception_handler:8 Error in event handler for (unknown): TypeError: Cannot read property 'options' of undefined
at start
My Weather Aplication works fine
check it out here: www.dardandemiri.com/weather/
but the error is there
Jeff
@adzam5
Apr 04 2016 20:40
@Juwdohr You have $('#on-btn').onClick(function() It should be $('#on-btn').click(function() or $('#on-btn').on('click', function()
Dardan Demiri
@dardandemiri
Apr 04 2016 20:41
Does anyone has any idea what's going on ?
Jeff
@adzam5
Apr 04 2016 20:43
@dardandemiri I'm not seeing any errors. The first time I loaded the page I saw a 404 for your favicon, but that's it
Dardan Demiri
@dardandemiri
Apr 04 2016 20:44
what do you men favicon
weather icon ?
Jeff
@adzam5
Apr 04 2016 20:46
No. favicon.ico is usually located in your sites root directory. It provides the icon you see usually on the left side of your tab in your browser. It's not required. I was just saying that was the only error I saw.
Dardan Demiri
@dardandemiri
Apr 04 2016 20:48
ahhh
thank you @adzam5
CamperBot
@camperbot
Apr 04 2016 20:48
dardandemiri sends brownie points to @adzam5 :sparkles: :thumbsup: :sparkles:
:star: 389 | @adzam5 | http://www.freecodecamp.com/adzam5
Jeff
@adzam5
Apr 04 2016 20:49
@dardandemiri Also, unrelated to your question, but you are loading jQuery version 1.11.3 through Google's CDN and also loading a local copy of jQuery 2.2.2
Juwdohr
@Juwdohr
Apr 04 2016 20:50
@adzam5 still not showing just those that are online.
Dardan Demiri
@dardandemiri
Apr 04 2016 20:50
yes Because I had problems with jQueyr so I loaded both ways
Jeff
@adzam5
Apr 04 2016 20:50
@dardandemiri Your weather app looks good though
Dardan Demiri
@dardandemiri
Apr 04 2016 20:50
I don't know which one is working :P
Thanks for your compliment
Jeff
@adzam5
Apr 04 2016 20:55
@Juwdohr I don't think the API call in your click function is necessary. You can assign classes in your first API call, kind of like what you are doing, and show/hide on click based on the class
@dardandemiri You're welcome
Dylan
@dhcodes
Apr 04 2016 20:58

I have a logic question regarding the Tic Tac Toe project if anyone has a second. My question is:

How do I get the game to realize there are 3 in a row?

I originally tried to make a multidimensional array with each sub array storing the ids of the winning blocks (ex. [1,2,3],[1,4,7] etc.) but I can't seem to write a function that checks those boxes I've clicked against each subarray.

Any thoughts on how one might do this?

Jeff
@adzam5
Apr 04 2016 20:58
@Juwdohr Also, your layout breaks in a narrow window. The status does not stay in time with the username
Dylan
@dhcodes
Apr 04 2016 20:58
I'll "hang up and listen" because I have to go for now. Thanks to anyone in advance
Stephen James
@sjames1958gm
Apr 04 2016 21:09
@RobertCC18 y === X should that be y === "X"
@dhcodes I created the following array of winning paths assuming 3x3 board
var paths = [
  [[0, 0],[0, 1],[0, 2]],
  [[1, 0],[1, 1],[1, 2]],
  [[2, 0],[2, 1],[2, 2]],
  [[0, 0],[1, 0],[2, 0]],
  [[0, 1],[1, 1],[2, 1]],
  [[0, 2],[1, 2],[2, 2]],
  [[0, 0],[1, 1],[2, 2]],
  [[2, 0],[1, 1],[0, 2]]];

paths.forEach(function(path) {
      if ((board[path[0][0]][path[0][1]] === player) &&
        (board[path[1][0]][path[1][1]] === player) &&
        (board[path[2][0]][path[2][1]] === player)) { then win for player }})
Juwdohr
@Juwdohr
Apr 04 2016 21:13
@adzam5 I noticed that it did that, was going to fix that after i got the basics working.
Jared Abel
@jaredabel
Apr 04 2016 22:32
i am trying to create a function where when i click on my table, it grabs that divs ID
<table class='center'>
  <tr>
    <td id='topLeft'></td>
    <td id='topCenter'></td>
    <td id='topRight'></td>
  </tr>
  <tr>
    <td id='centerLeft'></td>
    <td id='centerCenter'></td>
    <td id='centerRight'></td>
  </tr>
  <tr>
    <td id='bottomLeft'></td>
    <td id='bottomCenter'></td>
    <td id='bottomRight'></td>
  </tr>
</table>
and i want to be able to do something like
```
$(table).click(function(){
do something to the ID i clicked
Tyler Moeller
@TylerMoeller
Apr 04 2016 22:40
@jaredabel If you want the ID of the td element, you can use this.id:
$('td').click(function() {
  alert('The element with ID: ' + this.id + ' was clicked!');
})
Jared Abel
@jaredabel
Apr 04 2016 22:42
@TylerMoeller Thanks, i've added that into my other click function that was just for one ID
CamperBot
@camperbot
Apr 04 2016 22:42
jaredabel sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
Jared Abel
@jaredabel
Apr 04 2016 22:42
```
CamperBot
@camperbot
Apr 04 2016 22:42
:star: 490 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
Jared Abel
@jaredabel
Apr 04 2016 22:43
 $('#td').click(function() {
    if (board.indexOf(this.id >= 0)) {
      $(this.id).text(playerTeam);
      board[board.indexOf(this.id)] = playerTeam;
      console.log(board);
      playerTurn = false;
      enemyMove();
    }
i assume i need to add more stuff into line 3 of that to properly grab the id?
Tyler Moeller
@TylerMoeller
Apr 04 2016 22:44
@jaredabel #td will only work if you are clicking on an element with id td.
If it's just a <td> element, use $('td')
Jared Abel
@jaredabel
Apr 04 2016 22:45
hmm
Tyler Moeller
@TylerMoeller
Apr 04 2016 22:46
@jaredabel line 3 would be $('#' + this.id)
Jared Abel
@jaredabel
Apr 04 2016 22:47
aha!
Tyler Moeller
@TylerMoeller
Apr 04 2016 22:52
@jaredabel Nice :) now, remove the var from in front of your board, playerTeam, and compTeam variables so your click function can see them
Stephen James
@sjames1958gm
Apr 04 2016 22:57
@TylerMoeller My understanding is with jQuery you can do $(this) in an event handler
Tyler Moeller
@TylerMoeller
Apr 04 2016 23:00
@sjames1958gm Yes, $(this) and $('#' + this.id) would both work in @jaredabel's code.
Jared Abel
@jaredabel
Apr 04 2016 23:02
var checkWin = function(team){
        if (board[0] == team && board[1] == team && board[2] == team){
          console.log(team + 'wins');}

       else if (board[3] == team && board[4] == team && board[5] == team){
          console.log(team + 'wins');}
       else if (board[6] == team && board[7] == team && board[8] == team){
          console.log(team + 'wins');}
       else if (board[0] == team && board[3] == team && board[6] == team){
          console.log(team + 'wins');}
       else if (board[1] == team && board[4] == team && board[7] == team){
          console.log(team + 'wins');}
       else if (board[2] == team && board[5] == team && board[8] == team){
          console.log(team + 'wins');}
       else if (board[0] == team && board[4] == team && board[8] == team){
          console.log(team + 'wins');}
       else if (board[2] == team && board[4] == team && board[6] == team){
          console.log(team + 'wins');}
i also imagine there is a better way of doing this
but i think it will do for now
Jared Abel
@jaredabel
Apr 04 2016 23:10
best way to dump all my values from my table so i get a clean board?
Pete
@petegarvin1
Apr 04 2016 23:33
@jaredabel looks good :D
Jared Abel
@jaredabel
Apr 04 2016 23:36
@Spacecamel100 thanks, just have a nasty loop going on somewhere now when i try and reset the board
CamperBot
@camperbot
Apr 04 2016 23:36
jaredabel sends brownie points to @spacecamel100 :sparkles: :thumbsup: :sparkles:
:star: 395 | @spacecamel100 | http://www.freecodecamp.com/spacecamel100
Chris
@The-Mister
Apr 04 2016 23:46

Hey guys, having some trouble with some js code. I am working on my twitch api project and very confused as to why my arrays are not populating correctly.

var streamers = ["freecodecamp", "storbeck", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff", "esl_sc2", "cretetion", "valkrin", "lirik"];
  var allStreams = []; //will hold every streams API GET data
$(document).ready(function() {
    //iterating through list of streamers through twitch
    for (var i = 0; i < streamers.length; i++) {
      //API call for each stream
      $.getJSON('https://api.twitch.tv/kraken/streams/' + streamers[i] + '?callback=?', function(data) {
        //adding each user's twitch data to allStreams
        allStreams.push(data);
      });//end API call
      console.log(allStreams);
    };//for streamers length
  });//doc.ready

When I do a console.log(allStreams) directly following the .push, it displays the info, but if I do it as shown above, outside of the API call, it returns an empty array. Why is it doing this?

Wint3rNuk3
@Wint3rNuk3
Apr 04 2016 23:49
@The-Mister can you link your CodePen so I can give a look ?
Robert Richey
@0x0936
Apr 04 2016 23:49
@The-Mister .getJSON() is an asynchronous function. console.log() runs before you get a response from the API
@0x0936 What do you mean by that? I'm not familiar with asynchronous functions
Robert Richey
@0x0936
Apr 04 2016 23:52
@The-Mister your code is sending a request to a server for data. While your request is waiting for a response, the rest of your application is allowed to continue executing.
Chris
@The-Mister
Apr 04 2016 23:53
@0x0936 Ahhh ok. Is there a better way to assemble all the responses other than '.getJSON' or something like a wait for response function?
Wint3rNuk3
@Wint3rNuk3
Apr 04 2016 23:55
Wow i'm actually having the same kind of issue, I even looked up DOM readyState Property, I spent litterally my whole day on it, I can't seem to understand how to make my function execute AFTER all the .getJSON stuff gets done...
Back to you if I find out @The-Mister
Robert Richey
@0x0936
Apr 04 2016 23:56
@The-Mister there are a couple different ways to tackle this. You could easily do this with ES6 promises, or you could keep track of a counter and increment that counter each time .getJSON()'s callback executes. Once this counter equals the length of your streamers array, then you've received all responses back from all requests made
Chris
@The-Mister
Apr 04 2016 23:56
Thanks @Wint3rNuk3 , I'll let you know when I resolve my issue
CamperBot
@camperbot
Apr 04 2016 23:56
the-mister sends brownie points to @wint3rnuk3 :sparkles: :thumbsup: :sparkles:
:star: 291 | @wint3rnuk3 | http://www.freecodecamp.com/wint3rnuk3
Tyler Moeller
@TylerMoeller
Apr 04 2016 23:58
@The-Mister and @Wint3rNuk3 You can also make an ajax call with async: false
    streamers.forEach(function(streamer) {
      $.ajax({
        url: 'https://api.twitch.tv/kraken/streams/' + streamer,
        async: false
      })
      .done(function (data) {
        allStreams.push(data);
      })
    })
    console.log(allStreams);