These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Jul 2017
aRtoo
@artoodeeto
Jul 09 2017 00:05 UTC

hey guys. i have an error on my console. its on my object. the error is this unexpected token :

heres my object:

  var bgObject={
    [
    'description': 'clear sky',
    'day_icon': '01d',
    'night_icon': '01n',
    'dayImg': ,
    'nightImg':,
  ]  };
Diego Mayer
@Chrono79
Jul 09 2017 00:13 UTC
The last 2 properties haven't values
but why are you using brackets there?
korzo
@korzo
Jul 09 2017 00:15 UTC
@Arontbt It will always return word !== false (true) . And if word is false, it returns NaN
Diego Mayer
@Chrono79
Jul 09 2017 00:15 UTC
var bgObject={
    'description': 'clear sky',
    'day_icon': '01d',
    'night_icon': '01n',
    'dayImg': '', //or some value
    'nightImg': '' //or some value
};
Nick Cleary
@Hijerboa
Jul 09 2017 00:30 UTC
$.getJSON("https://api.darksky.net/forecast/ddb79a723468dc5748c73fd586408cdc/50,50", function(forcast) {
            console.log(forcast);
        });
Can someone tell me why this isn't outputting anything? I put the link straight into my adress bar and it works, but this doesn't output anything at all, no matter where I put it or call it in my program
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 00:31 UTC

can you help me with this
from an API i am receiving [1,2,3,4,[ 1,2,3,4,[ ]]] or [1,2,3,4,[ ]]
i) for [1,2,3,4,[ 1,2,3,4,[ ]]] i need

<sometag>
   <sometag>
   </sometag>
</sometag>

ii) for [1,2,3,4,[ ]]

<sometag>
</sometag>

What i mean by that I will always have an array which will have its 5th element also array, if the 5th element array length is 0 then i need simple tag else the tag must be nested.
these array values will be used as props with those tags in react

CallMeOrange
@EgnaroDev
Jul 09 2017 01:01 UTC
@Hijerboa is this because of forcast?
forecast?
Moisés Man
@moigithub
Jul 09 2017 01:02 UTC
darksky dont have cors suport..
if u check ur BROWSER devtools/console u should see an error @Hijerboa
to bypass.. u need to do jsonP request
Nick Cleary
@Hijerboa
Jul 09 2017 01:02 UTC
@MCTwoDigitZero I found the problem
its has to do with the darksky api not allowing open api's
CallMeOrange
@EgnaroDev
Jul 09 2017 01:02 UTC
@Hijerboa Ah I see
aRtoo
@artoodeeto
Jul 09 2017 01:09 UTC
hi guys. this is long. sorry but i just need help. its been 5 hours. but i have i for loop with if and else if statement inside. my condition is to check if the icon of the json file is true it will get the link of the arrays of objects. heres the code:
$(document).ready(function()
{
  //images for background.
  var bgImg=[
    {
    'description': 'clear sky',
    'day_icon': '01d',
    'night_icon': '01n',
    'dayImg': 'https://unsplash.com/search/clear-sky?photo=-KUD807lwSo',
    'nightImg': 'https://unsplash.com/search/clear-sky?photo=ewzHvxHl-Ak'
  },

  {
  'description': 'few clouds',
  'day_icon': '02d',
  'night_icon': '02n',
  'dayImg':  'https://unsplash.com/search/clear-sky?photo=avFAINgEOQ0',
  'nightImg':'https://unsplash.com/search/clouds-night?photo=sUlEmXjrRxI'
},

  {
  'description': 'scattered clouds',
  'day_icon': '03d',
  'night_icon': '03n',
  'dayImg':'https://unsplash.com/search/clouds-days?photo=E9aetBe2w40',
  'nightImg': 'https://unsplash.com/search/clouds-night?photo=h_gwdi8UH2o'
},

  {
  'description': 'broken clouds',
  'day_icon': '04d',
  'night_icon': '04n',
  'dayImg': 'https://unsplash.com/search/weather-clouds?photo=GpMiWt9KAkA',
  'nightImg': 'https://unsplash.com/search/weather-clouds?photo=E3rMBrxqKRo'
},

  {
  'description': 'shower rain',
  'day_icon': '09d',
  'night_icon': '09n',
  'dayImg': 'https://unsplash.com/search/rainy?photo=mYOea-xnu-k',
  'nightImg': 'https://unsplash.com/search/rainy?photo=T7RlFC8dH60'
},

  {
  'description': 'rain',
  'day_icon': '10d',
  'night_icon':'10n',
  'dayImg': 'https://unsplash.com/search/rainy?photo=RJH-SCKMhmo',
  'nightImg':'https://unsplash.com/search/weather-rain?photo=H0lTOg1t_0o'
},

  {
  'description': 'thunderstorm',
  'day_icon': '11d',
  'night_icon': '11n',
  'dayImg': 'http://3.bp.blogspot.com/-pHv5T4iewKA/UaMN86nf4lI/AAAAAAAAAhg/G2JSWQNEfrU/s1600/1.png',
  'nightImg': 'https://unsplash.com/search/weather-clouds?photo=NcTQ602gKLI'
},

  {
  'description': 'snow',
  'day_icon': '13d',
  'night_icon': '13n',
  'dayImg': 'https://unsplash.com/search/snow?photo=F3ePNdQb_Lg',
  'nightImg': 'https://unsplash.com/search/snow-night?photo=uCzBVrIbdvQ'
},

  {
  'description': 'mist',
  'day_icon': '50d',
  'night_icon': '50n',
  'dayImg': 'https://unsplash.com/search/mist?photo=h3y3XPXKoeY',
  'nightImg': 'https://unsplash.com/search/mist?photo=zboO0K1WfY4'
}
  ];

      //variables for the url
      var lat; //latitude
      var lon;  //longitude
      var imp = 'imperial'; //unit of measurement
      var met = 'metric'; //unit of measurement

      //getting img icon, Global for we can use it anywhere in the code.
      var imgIcon;

      //retreving data for weather
      function weatherData(){
      //API main link
      var api = 'http://api.openweathermap.org/data/2.5/weather?';
      //API key. you need to register to get a unique key
      var key = '8bc4ea333a5f2b734509a80ef5ce88d6';


      //calling API using ajax // practice getJSON too
      $.ajax({
        type:'GET', //GET method to get data
        //url:'http://api.openweathermap.org/data/2.5/weather?lat=33.7887586&lon=-117.8836668&units=imperial&APPID=8bc4ea333a5f2b734509a80ef5ce88d6',
        url: api + 'lat=' + lat + '&' + 'lon=' + lon + '&' + 'units=' + imp + '&' + 'APPID=' + key, //url link consist of varialbles. check top url comment for the values
        //success funciton with a parameter that holds the json or datas
        success: function(data){

        imgIcon = data.weather[0].icon;

        //returning image
        var img = 'http://openweathermap.org/img/w/' + data.weather[0].icon + '.png';

        $('.city-name').text(data.name);
        $('#temperature').text(data.main.temp + '°');
        $('#icon_img').attr('src',img);
        $('.pressure').text(data.main.pressure);
        $('.humidity').text(data.main.humidity);
        $('.speed').text(data.wind.speed);
        $('.deg').text(data.wind.deg + '°');
        $('.sunrise').text(data.sys.sunrise);
        $('.sunset').text(data.sys.sunset);
        }
      })
    }



    //bgImg[i].day_icon day link img
    //bgImg[i].night_icon night link img

        for(var i=0; i<=bgImg.length; i++){
          if(bgImg[i].day_icon === imgIcon ){
              //$('.bg').attr('src', bgImg[i].dayImg);
              console.log('yes!!');
          }else if(bgImg[i].night_icon === imgIcon) {
            //$('.bg').attr('src', bgImg[i].nightImg);
            console.log('yes!!');
          }
        }




    //initial syntax for getting current location. refer to this link https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation
    navigator.geolocation.getCurrentPosition(function(pos){
      lat =  pos.coords.latitude;  //values for latitude
      lon = pos.coords.longitude; //values for longitude
    weatherData();
    })



});
John
@AnonymousLords
Jul 09 2017 01:10 UTC
@artoodeeto You posted the same thing on 3 chats :P
aRtoo
@artoodeeto
Jul 09 2017 01:11 UTC
@John-freeCodeCamp yes bro. because someone might help me on other rooms
help bro
John
@AnonymousLords
Jul 09 2017 01:12 UTC
@artoodeeto Im not that advanced on JS, but someone else might be able to help you. @ them
I gtg, but someone can help me i can respond in the morning, here my issue:
var myArray = [["John", 23], ["dog", 3]];
myArray.pop(["John", 23]);
myArray.unshift(["Paul, 35"]);
https://www.freecodecamp.org/challenges/manipulate-arrays-with-unshift
My code isnt working?
Frank McCroy
@fmccroy
Jul 09 2017 01:15 UTC
Your quotes are different, just looking at your example. Does the 35 in the unshift need to be a string?
@John-freeCodeCamp You need to put it in as myArray.unshift(["Paul", 35]); Which is slightly different than what you showed us.
Gulsvi
@gulsvi
Jul 09 2017 01:25 UTC
@artoodeeto The issue with the code above is that the API only works over HTTP and the for loop needs to be < not <= :: for(var i=0; i<=bgImg.length; i++){
(trying to help avoid duplication of efforts here, as this question has been posted by @artoodeeto in multiple rooms)
Moisés Man
@moigithub
Jul 09 2017 01:26 UTC

@artoodeeto would be easier if instead of array.. u make a lookup table
object inside objects
u could use whatever data.weather[0].icon values have as key ie... lets supose that returns "rain"
soo u make ur lookup table like

  var bgImg=    { 
"rain":{
    'description': 'clear sky',
    'day_icon': '01d',
    'night_icon': '01n',
    'dayImg': 'https://unsplash.com/search/clear-sky?photo=-KUD807lwSo',
    'nightImg': 'https://unsplash.com/search/clear-sky?photo=ewzHvxHl-Ak'
  },
///... 
}

then u NO need a loop to get those img data
var img= bgImg[data.weather[0].icon]; should be enough

Moisés Man
@moigithub
Jul 09 2017 01:39 UTC
backticks on its OWN line @moyamanuel
Manuel Moya
@moyamanuel
Jul 09 2017 01:40 UTC
function rot13(str) { // LBH QVQ VG!

  var test = str.split(' ');
  var testArr = [];
  var finalArr = [];
  var final = "";
  for (var i=0;i < test.length;i++)
    {
      for (var letter=0; letter < test[i].length;letter++)
        {
          testArr.push(test[i].charCodeAt(letter));

        }
    }

  for (var a=0;a < testArr.length;a++)
    {
      finalArr.push(testArr[a] - 13);
    }

  for (var nums = 0;nums < finalArr.length;nums++)
    {
      final += String.fromCharCode(finalArr[nums]);
    }
  return final;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
There you go, sorry :sweat_smile:
The output returned is F8EEC5DECAM6
Moisés Man
@moigithub
Jul 09 2017 01:42 UTC
www.asciitable.com
A ascii code is 65
if u do 65-13 u get 52
String.fromCharCode(52) is "4"
www.rot13.com if u check here A should be decoded as N
Manuel Moya
@moyamanuel
Jul 09 2017 01:45 UTC
Right, I have my code set so it retrieves the char code value of each letter and subtracts 13 from it, then pushes it to an array.
Frank McCroy
@fmccroy
Jul 09 2017 01:46 UTC
@moyamanuel What happens if you get an “A” to decode? Subtracting 13 from that becomes a number. You need to figure out how to wrap around to the end of the alphabet and go from there.
Moisés Man
@moigithub
Jul 09 2017 01:46 UTC
soo.. A-1 should be Z
A-2 should be Y ...
A-13 should be N
u need to keep ur values on A-Z range...
Manuel Moya
@moyamanuel
Jul 09 2017 01:47 UTC
Ah, I see! Thanks guys @fmccroy @moigithub !
CamperBot
@camperbot
Jul 09 2017 01:47 UTC
moyamanuel sends brownie points to @fmccroy and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @fmccroy |http://www.freecodecamp.com/fmccroy
:star2: 3482 | @moigithub |http://www.freecodecamp.com/moigithub
aRtoo
@artoodeeto
Jul 09 2017 02:17 UTC
someone knows how to post a project on codepen that is a http? not https? i didnt know aboout it and it was too late?? help??
CallMeOrange
@EgnaroDev
Jul 09 2017 02:26 UTC
@artoodeeto Its impossible even if you change codepen to http
There is no way, its https period
If you are using an API that is http, you have no choice but to use another one that is https for codepen
aRtoo
@artoodeeto
Jul 09 2017 02:27 UTC
@MCTwoDigitZero omg. someone bite me!!
CallMeOrange
@EgnaroDev
Jul 09 2017 02:27 UTC
@artoodeeto Its better to use an API that is https instead of asking how to post project on codepen that is http
aRtoo
@artoodeeto
Jul 09 2017 02:29 UTC
@MCTwoDigitZero but im already done. i just knew it when i was about to post it know. grrr. do you a link on darksky weathe r?
I have two APIs for https
Darksky api or apixu.com
aRtoo
@artoodeeto
Jul 09 2017 02:31 UTC
@MCTwoDigitZero thanks. omg!! im tired!
CamperBot
@camperbot
Jul 09 2017 02:31 UTC
artoodeeto sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
:cookie: 460 | @mctwodigitzero |http://www.freecodecamp.com/mctwodigitzero
CallMeOrange
@EgnaroDev
Jul 09 2017 02:31 UTC
No problem
Frank McCroy
@fmccroy
Jul 09 2017 02:31 UTC
Someone made a weather API just for FCC, you can see it here: freeCodeCamp/freeCodeCamp#15598
aRtoo
@artoodeeto
Jul 09 2017 02:32 UTC
@MCTwoDigitZero btw. can i host my weather app and pass the link??
Mai Thinh
@mthinh
Jul 09 2017 02:32 UTC
``

```
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var arrSources = Object.keys(source);

collection.forEach(function(obj){

arrSources.forEach(function(sou){

  if(obj.hasOwnProperty(sou)&& obj[sou]===source[sou] ){
   arr.push(obj); 

  }

});

});

// Only change code above this line
return arr;
}

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
I wonder how I stop them push the same obj into array ?
pls help

CallMeOrange
@EgnaroDev
Jul 09 2017 02:35 UTC
@fmccroy Do you think it is ok to use a key in codepen?
Frank McCroy
@fmccroy
Jul 09 2017 02:37 UTC
@MCTwoDigitZero I did it to complete the challenge and since it appeared that I had to, but someone else could potentially steal it. The link I posted above does not involve using a key, or at least not our own personal key.
CallMeOrange
@EgnaroDev
Jul 09 2017 02:38 UTC
Yeah but I think it is ok to use a key if we have just free plan
I did it tho
Frank McCroy
@fmccroy
Jul 09 2017 02:40 UTC
@MCTwoDigitZero As long as we can’t be charged it shouldn’t be a big deal if someone else sees the key or not. I figure nobody will see my code anyway, unless I decide to link to it from a portfolio page later.
CallMeOrange
@EgnaroDev
Jul 09 2017 02:42 UTC
I see
Moisés Man
@moigithub
Jul 09 2017 02:43 UTC
u only push AFTER check ALL sources keys/values, not only first match @mthinh
Mai Thinh
@mthinh
Jul 09 2017 02:44 UTC
yeah i realized that mistake , but dont know how to fix
Moisés Man
@moigithub
Jul 09 2017 02:46 UTC
u could use a flag..
ie allok = true;
arrsourc.foreach( s=> {
if( props/value dont match) allok = false;
}
//then evaluates if allok is true.. means all props/values matched soo u can push
Joseph Joe
@JoeTinnySpace
Jul 09 2017 02:47 UTC
$(document).ready(function(){
  var twitchArray = ["quickybaby", "sinatraaow", "freecodecamp", "yuuie", "brunofin", "comster404"];
  for(var i= 0; i< twitchArray.length; i++){
    $.ajax({
    type: 'GET',
    url: 'https://api.twitch.tv/kraken/streams/'+twitchArray[i],
    headers: {
                'Client-ID': 'juhdji5qs4zu4424jfyjw63oxoh70'
    },
    success: function(data){
      //code for markup styling results
      var htmlCol = '<div class="col-xs-12">';
      if(data.stream!=null){
        //for data input
        var display_name = data.stream.channel.display_name;
        var gameName = data.stream.channel.game;
        var followers = data.stream.channel.followers;
        var viewers = data.stream.viewers;
        //var memberLink = data.stream.links.self;

        console.log(data.stream);
        console.log(twitchArray[i]);
      }//if closing
      if(data.stream==null){
       // console.log(twitchArray[i]+" is offline");
      }


    }
  });//ajax closing
  }

});
Why the console.log isn't working ? It logs an 'undefined' value
Moisés Man
@moigithub
Jul 09 2017 02:47 UTC
another way is using .every method @mthinh
Mai Thinh
@mthinh
Jul 09 2017 02:47 UTC
@moigithub ok tks
@moigithub thank you
CamperBot
@camperbot
Jul 09 2017 02:47 UTC
mthinh sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3483 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph Joe
@JoeTinnySpace
Jul 09 2017 02:48 UTC
console.log(twitchArray[i]);
this line
Moisés Man
@moigithub
Jul 09 2017 02:49 UTC
cuz ajax is async
and for/loop is not
async means.. ur data will be available later.. cuz server request takes times to reply back
soo when ur ajax callback function gets called for loop already finished.. soo i dont have the "initial" value when ajax was called. but will have the last value
i === twitchArray.length
Joseph Joe
@JoeTinnySpace
Jul 09 2017 02:51 UTC
so I can't fix it this way ?
using twitchArray[i] ?
alright,
so I can create a variable , right?
Moisés Man
@moigithub
Jul 09 2017 02:52 UTC
soo doing twitchArray[ twitchArray.length ] dont exist.. returning undefined
CallMeOrange
@EgnaroDev
Jul 09 2017 02:52 UTC
last index is always blah.length - 1
I think :wink:
Moisés Man
@moigithub
Jul 09 2017 02:53 UTC
to solve u need to keep i value .. u can do that using functions or using block scope
Ken Haduch
@khaduch
Jul 09 2017 02:53 UTC
@JoeTinnySpace - try it with let i = 0; instead of var i = 0; because using let makes the actual current value of the variable available in the closure. (That's an ES6 feature, if you don't know.) Try it and see if it works.
Joseph Joe
@JoeTinnySpace
Jul 09 2017 02:54 UTC
@moigithub @khaduch thanks, I'll try
CamperBot
@camperbot
Jul 09 2017 02:54 UTC
joetinnyspace sends brownie points to @moigithub and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3083 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 3484 | @moigithub |http://www.freecodecamp.com/moigithub
AlliBun
@AlliBun
Jul 09 2017 02:59 UTC
I am working on my weather app, and I am trying to set up different backgrounds for different times of day/weather conditions, If I wanted to do this, would this statement work? if (condition == snowy||blizzard||blowing snow && time == day){background = //url}; //I have a function later that adds the url background to the body tags
2895388807
@2895388807
Jul 09 2017 03:00 UTC

//初始化变量
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for( var i = 0; i < contacts.length; i++ ){
if(contacts[i]===firstName){
if(contacts.hasOwnProperty(prop)){
return contacts[prop];
}
}return "No such contact";
}return "No such property";

// 请把你的代码写在这条注释以上
}

// 你可以修改这一行来测试你的代码
lookUp("Akira", "likes");

Joseph Joe
@JoeTinnySpace
Jul 09 2017 03:01 UTC
@AlliBun Not the answer, but I did that project using switch case( if that helps)
AlliBun
@AlliBun
Jul 09 2017 03:01 UTC
oh, I forgot that switch case exists, thank you @JoeTinnySpace
CamperBot
@camperbot
Jul 09 2017 03:01 UTC
allibun sends brownie points to @joetinnyspace :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @joetinnyspace |http://www.freecodecamp.com/joetinnyspace
2895388807
@2895388807
Jul 09 2017 03:02 UTC
what wrong with it >? im going crzay i spend serval hours about this
Frank McCroy
@fmccroy
Jul 09 2017 03:03 UTC
@2895388807 Your return statements are too early, they are breaking your loop. As soon as the program hits return, it breaks out of the loop and does not come back.
Ken Haduch
@khaduch
Jul 09 2017 03:05 UTC

@AlliBun - you conditional test is not written correctly - you have this: if (condition == snowy||blizzard||blowing snow && time == day) and you would have to have it fully written out as

if (condition == "snowy"||condition == "blizzard"||condition == "blowing snow" && time == day)

And I put your condition values in quotes, thinking that they might be string values? I didn't address the value for time == day... but you get the idea.

2895388807
@2895388807
Jul 09 2017 03:06 UTC
@fmccroy so how to fix it? i still dont know how to place this return
Ken Haduch
@khaduch
Jul 09 2017 03:06 UTC
@2895388807 - one thing that is wrong is contacts[i] === firstName - you have to be accessing the property contacts[i].firstName === firstName. That's a start.
2895388807
@2895388807
Jul 09 2017 03:07 UTC
@khaduch yeh
Frank McCroy
@fmccroy
Jul 09 2017 03:07 UTC
@2895388807 Instead of using return in the loop, set a variable as a flag. After the loop, check to see if the flag changed, ie the property was found.
Ken Haduch
@khaduch
Jul 09 2017 03:07 UTC
You might have other problems besides that. Like mainly you have to use contacts[i] any place that you are referencing an object from the array. @2895388807
2895388807
@2895388807
Jul 09 2017 03:09 UTC
ok thx guys i try it
Ken Haduch
@khaduch
Jul 09 2017 03:09 UTC
@2895388807 - then you have to be a little more careful with how you are structuring your returns, but you should try to format that and properly indent the code blocks to make is more obvious what is going on.
@2895388807 - it is fine to return either the property, if you find it, or the "No such property", if you found a matching firstName but it didn't contain the property. One thing that trips a lot of people up is returning "No such contact" - you have to make sure that you get through the entire list of contacts before you can safely return that.
2895388807
@2895388807
Jul 09 2017 03:13 UTC
this question is so hard.
display no such contact
i think my problem in if(contacts[i].firstName===firstName)
Frank McCroy
@fmccroy
Jul 09 2017 03:19 UTC
@2895388807 You can’t just look at one name and return that it wasn’t found, you have to make it through the whole list. The same goes for the property.
Chuck Wongus
@YesImChuck
Jul 09 2017 03:19 UTC
Hey all! Maybe someone can help me with what I am doing this completely wrong. I am working on the cipher. Am I able to put an if statement in a loop? Below is my code. I have converted the string to an array of character numbers
function rot13(str) { // LBH QVQ VG!
  var map = Array.prototype.map;

  var charNums = map.call(str, function(x) { 
  return x.charCodeAt(0); 
});

  // iterate through Array except 
  return charNums;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
connor-5
@connor-5
Jul 09 2017 03:22 UTC
@YesImChuck yes you can put a conditional inside a loop. So now that you have the array of character numbers what are you doing next?
Frank McCroy
@fmccroy
Jul 09 2017 03:22 UTC
@YesImChuck A simple answer is, yes you can put an if statement into a loop. You will probably need an if statement to figure out what to do with a character that is not a letter if you subtract 13 from it.
Chuck Wongus
@YesImChuck
Jul 09 2017 03:23 UTC
My plan is to iterate through the array for characters to add 13 if they are letters
2895388807
@2895388807
Jul 09 2017 03:23 UTC
thx man
connor-5
@connor-5
Jul 09 2017 03:23 UTC
Yeah that'll work. Make sure you account for things that won't be letters after adding thirteen though (anything after n)
Chuck Wongus
@YesImChuck
Jul 09 2017 03:24 UTC
Well connor, I didn't even think of that. That puts a whole new problem to figure out. Lol
connor-5
@connor-5
Jul 09 2017 03:25 UTC
Yeah it was a pain for me when I did it haha
Frank McCroy
@fmccroy
Jul 09 2017 03:25 UTC
@YesImChuck You will see what happens quick enough when your program gives ALMOST the right answer, except for 2-3 letters. :)
Chuck Wongus
@YesImChuck
Jul 09 2017 03:26 UTC
Lol, thank y'all for your help!
Bradley Sands
@sandsbe
Jul 09 2017 03:29 UTC
Working with if statement and indexOf and having issues.
  var counter = 0;
  var indexLeft = 0;
  var indexRight = 0;
  for (i = 0; i < perms; i++) {
    for (j = 1; j < (str.length-1); j++) {
      indexLeft = Number(permArr[i][(j-1)]);
      indexRight = Number(permArr[i][(j+1)]);
      if (args[Number(permArr[i][j])].indexOf(indexLeft) === 0 || args[Number(permArr[i][j])].indexOf(indexRight) === 0 );
      counter++;
    }
    if (counter>0) {
      delete permArr[i];
    }
    counter = 0;
  }
The if statement keeps hitting the counter, even when the indexOf should be returning -1 for both comparisons
Two falses don't equal a true, correct?
Moisés Man
@moigithub
Jul 09 2017 03:42 UTC
;<-- statement terminator @sandsbe
Bradley Sands
@sandsbe
Jul 09 2017 03:43 UTC
Very nice find. I can work with this. Thanks @moigithub
CamperBot
@camperbot
Jul 09 2017 03:43 UTC
sandsbe sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3485 | @moigithub |http://www.freecodecamp.com/moigithub
background stay when scrolling but how do I make box also stay like background-attachment: fixed;?
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:35 UTC
@MCTwoDigitZero you can use position: fixed
@MCTwoDigitZero position: sticky moves with the scroll until it get to the top of the document then it stops
CallMeOrange
@EgnaroDev
Jul 09 2017 04:44 UTC
@Lumexralph Yeah I used position: fixed but didnt work
is this because of another position? position: relative; maybe I can do position: relative, fixed?
Well I removed relative, it works but how do I use both?
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:47 UTC
@MCTwoDigitZero why do you want to use 2 position style attributes ? on an element
CallMeOrange
@EgnaroDev
Jul 09 2017 04:48 UTC
I need position: fixed; to make the box to stay when scrolling
I used margin-bottom to make background bigger but I wanted the box to stay...
surferpilgrim
@surferpilgrim
Jul 09 2017 04:49 UTC
so the first chunk of my program translates the inputs into an array of strings so an input like [580] would translate into ["500","80"]. the inner function ""translator" should take that string array match the corresponding values to their roman numeral counterparts so "500" would match with "D" and "80" would match with "LXXX". the ultimate goal is to have the complete function take an input and return an array of it's matching roman values (so ["500","80"] would return ["D","LXXX"] ). This is the roman numeral algorithm challenge I'm not interested in anyone posting the answer, that's not what I'm asking for, all I'm looking for is faults in my code that I could improve so that it could return what I want.
function convertToRoman(num) {
var nums = num.toString().split("");
  var  len = nums.length;
  var answer = nums.map(function(n,i){
    return n + (Array(len - i-1).fill(0)).join("");
  });
  var match =
function translator(id,answer){
var inputs ={ 
"1": "I",
 "2":"II",
"3":"III",
"4":"IV",
 "5":"V",
 "6":"VI",
"7": "VII",
 "8":"VIII",
 "9":"IX",
 "10":"X",
 "20":"XX",
"30":"XXX",
"40":"XL",
"50": "L",
"60":"LX",
 "70":"LXX",
"80":"LXXX",
"90":"XC",
"100":"C",
"200":"CC",
"300": "CCC",
"400":"CD",
"500":"D",
"600":"DC",
"700": "DCC",
"800":"DCCC",
"900": "CM",
 "1000": "M"};
  var response = [];
  for(var key in inputs){
if(answer.indexOf(key)!==-1){
  response.push(inputs[key]);
}}};
 return response;
}
 convertToRoman(36);
CallMeOrange
@EgnaroDev
Jul 09 2017 04:49 UTC
or should I use something else instead of margin-bottom to make background bigger so I dont have to use position: fixed?
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:50 UTC
@MCTwoDigitZero try it out
CallMeOrange
@EgnaroDev
Jul 09 2017 04:50 UTC
@Lumexralph What else can I make background bigger?
margin-bottom is only thing I know :/
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:54 UTC
@MCTwoDigitZero you background-size ?
CallMeOrange
@EgnaroDev
Jul 09 2017 04:54 UTC
Yeah I found background-size: 100%,100%;
I can change cover to 100%,100%
Hm... that became worse
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:56 UTC
@surferpilgrim var response = []; is defined in the inner function, it's not available to the converToRoman function scope, that'll return a reference error
@MCTwoDigitZero :laughing:
surferpilgrim
@surferpilgrim
Jul 09 2017 04:56 UTC
@Lumexralph should response be a global variable?
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:58 UTC
@surferpilgrim if you want to access it from outside the function, you should think of doing that or another way around it
CallMeOrange
@EgnaroDev
Jul 09 2017 04:58 UTC
perfect, I used auto, 100% instead
@Lumexralph thanks
CamperBot
@camperbot
Jul 09 2017 04:58 UTC
mctwodigitzero sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2023 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:58 UTC
@MCTwoDigitZero CSS is another beast!!!
CallMeOrange
@EgnaroDev
Jul 09 2017 04:59 UTC
:)
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:59 UTC
@surferpilgrim for the later part of the code to generate the roman numerals, you can still use map
Bradley Sands
@sandsbe
Jul 09 2017 05:15 UTC
Anyone finish the No Repeats Please challenge?
Long Nguyen
@longnt80
Jul 09 2017 05:17 UTC
@sandsbe yes
Bradley Sands
@sandsbe
Jul 09 2017 05:19 UTC
@longnt80 what's the most basic way to build the list of permutations?
i.e. 'str = "aaabb"`
str="aaabb"
Long Nguyen
@longnt80
Jul 09 2017 05:22 UTC
I used heap's algorithm
@sandsbe if you're good with math, you can write your own algorithm, but I can't understand the permutation so I had to used heap's
Bradley Sands
@sandsbe
Jul 09 2017 05:25 UTC
I thought I was good with math until this question came about
@longnt80 thanks for the link. I wrote my own stuff but it only solved for have of the answers. In the end, the permutations were off. Back to square one.
CamperBot
@camperbot
Jul 09 2017 05:26 UTC
sandsbe sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 431 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Jul 09 2017 05:31 UTC
@sandsbe np
Sanket Chaudhari
@sanket143
Jul 09 2017 05:37 UTC
Mai Thinh
@mthinh
Jul 09 2017 05:38 UTC
@sanket143 nice
Sanket Chaudhari
@sanket143
Jul 09 2017 05:39 UTC
thanks but have some problem @mthinh
CamperBot
@camperbot
Jul 09 2017 05:39 UTC
sanket143 sends brownie points to @mthinh :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @mthinh |http://www.freecodecamp.com/mthinh
Sanket Chaudhari
@sanket143
Jul 09 2017 05:39 UTC
when you enter to night mode and back to day mode.... the :hover class stops working @mthinh
Mai Thinh
@mthinh
Jul 09 2017 05:44 UTC
@sanket143 im sr, i dont know
Sanket Chaudhari
@sanket143
Jul 09 2017 05:45 UTC
@mthinh How could I fix it
aRtoo
@artoodeeto
Jul 09 2017 06:13 UTC
how do you get time?? like change it to non military time?
//get time
        var date = new Date();
        var hours = date.getHours(2230);
        console.log(hours);
Luis
@zdrifted
Jul 09 2017 06:27 UTC
Any idea why this algorithm isn't returning the index? I'm not allowed to use str.indexOf()
function getIndexOf(char, str) {
  // your code here
  var splitStr = str.split("");
  var maxIndex = splitStr.length - 1;

  console.log(splitStr, maxIndex);

  splitStr.forEach(function(letter, index) {
    console.log('args: ',letter, index);
    if (letter === char) {
      return index;
    } else if (maxIndex === index) {
      return -1;
    }

  });
}

getIndexOf('l', 'luis');
LiciniusRex
@hashtagyolo1
Jul 09 2017 06:29 UTC
morning folks
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:31 UTC
@Rushh forEach method of an array returns undefined
Luis
@zdrifted
Jul 09 2017 06:31 UTC
Why is index undefined?
aRtoo
@artoodeeto
Jul 09 2017 06:31 UTC
@Rushh reading it right now cant understand shit.
Luis
@zdrifted
Jul 09 2017 06:32 UTC
It does look confusing. Try this? https://www.youtube.com/watch?v=PjVed86oPKk
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:32 UTC
@Rushh forEach is best used for a side-effects, have a variable not in the forEach scope, maybe global then assign the index to it
@Rushh then you can return it in the scope of your function and not the forEach callback scope
Luis
@zdrifted
Jul 09 2017 06:34 UTC
Oh so it's similar to needing an IIFE in for loops? It's an issue with index no longer being defined?
I think I see what you mean
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:37 UTC
@Rushh it's the way forEach was constructed
Luis
@zdrifted
Jul 09 2017 06:38 UTC
Tried adding a global variable to track currentIndex but it's still not working. Weird because it is correctly logging out index when I added a console.log
It's just ignoring the if expressions
function getIndexOf(char, str) {
  // your code here
  var splitStr = str.split("");
  var maxIndex = splitStr.length - 1;
  var indexFound;

  splitStr.forEach(function(letter, index) {
    if (letter === char) {
      indexFound = index;
    } else if (maxIndex === index) {
      indexFound = -1;
    }
  });

  return indexFound;
}

getIndexOf('l', 'luis');
Now I'm getting -1 when I should get 0
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:41 UTC
@Rushh how about removing the else if statement
why do you need it?
Luis
@zdrifted
Jul 09 2017 06:43 UTC
I need to return -1 if char is not found in the string
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:46 UTC
@Rushh since you know that indexFound will always contain a value if it is in the string using for each, if there's no value, indexFound will be undefined, you can use ternary for that
@Rushh a simpler way initialize indexFound with -1
@Rushh so if there's not match it'll always be -1
@Rushh something like this
function getIndexOf(char, str) {
  // your code here
  var splitStr = str.split("");
  var maxIndex = splitStr.length - 1;
  var indexFound = -1;

  splitStr.forEach(function(letter, index) {
    if (letter === char) {
      indexFound = index;
    }
  });

  return indexFound;
}

getIndexOf('l', 'luis');
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:52 UTC
@Rushh but what this function will do is that. it'll return the last index the char was found and not the first, if that order is included then you should think of how to hold on to the first match
Luis
@zdrifted
Jul 09 2017 06:53 UTC
Oh I see
function getIndexOf(char, str) {
  // your code here
  var letters = str.split("");
  var indexFound;

  letters.forEach(function(letter, index) {
    console.log(letter, index);
    if (letter === char) {
      indexFound = index;
    }
  });

  if (indexFound >= 0) {
    return indexFound;
  }

  return -1;
}

getIndexOf('l', 'luis');
This works but I'm failing the tests. I'm going to email them and see if there is an issue with the tests they are using
Luis
@zdrifted
Jul 09 2017 06:59 UTC
Nvm I see what you mean about saving the first index found
aRtoo
@artoodeeto
Jul 09 2017 07:09 UTC
why im getting 0??
var date = new Date(1499655885);
        var hours = date.getHours();
        console.log(hours);
Luis
@zdrifted
Jul 09 2017 07:09 UTC
Took a break and got it! Thanks @Lumexralph
CamperBot
@camperbot
Jul 09 2017 07:09 UTC
rushh sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2024 | @lumexralph |http://www.freecodecamp.com/lumexralph
Mai Thinh
@mthinh
Jul 09 2017 07:10 UTC
function convertHTML(str) {
  // &colon;&rpar;
  var strArr=[];
  strArr=str.split('');
for(var i =0;i<strArr.length;i++){
  switch(strArr[i]){
    case "&":
      strArr[i]='&amp;';
      break;
    case "<":
      strArr[i]='&lt;';
      break;  
    case ">":
      strArr[i]='&gt;';
      break;  
    case '"':
      strArr[i]='&quot;';
      break;  
    case "'":
      strArr[i]='&apos;';
      break;  

  }
}
  return strArr.join('');
}

convertHTML("Dolce & Gabbana");
Can anyone explain that why cant I use forEach instead of for loop?
Pethaf
@Pethaf
Jul 09 2017 07:20 UTC
What's keeping you from using a forEach?
Mai Thinh
@mthinh
Jul 09 2017 07:21 UTC
I tried to use forEach but it doesnt work
Long Nguyen
@longnt80
Jul 09 2017 07:22 UTC
@mthinh show your code using forEach
Mai Thinh
@mthinh
Jul 09 2017 07:23 UTC
strArr.forEach(function(val){})
Opp sr im not on pc now
Long Nguyen
@longnt80
Jul 09 2017 07:26 UTC
Mai Thinh
@mthinh
Jul 09 2017 07:27 UTC
Oh i didnt pass i parameter , why is that ?
Luis
@zdrifted
Jul 09 2017 07:27 UTC
How do I get rid of these annoying notifications
Nvm found it. Those should be turned off by default
Long Nguyen
@longnt80
Jul 09 2017 07:29 UTC
@mthinh the function in forEach take 3 parameters: arr.forEach(function callback(currentValue, index, array)
you can see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
Pethaf
@Pethaf
Jul 09 2017 07:29 UTC
You don't have to provide a function with three parameters.
Long Nguyen
@longnt80
Jul 09 2017 07:30 UTC
@Pethaf of course, but he should know all three
Luis
@zdrifted
Jul 09 2017 07:30 UTC
@artoodeeto If you find yourself struggling with FCC then I would definitely recommend Udemy or another site that offers courses for cheap. I quit trying to get the FCC certificates and made a lot more progress
FCC seems more like a great place for computer science majors or people who have already been self studying for a long time through other resources. It's more of a place to test your progress
Mai Thinh
@mthinh
Jul 09 2017 07:32 UTC
Thank you Long Nguyen
Long Nguyen
@longnt80
Jul 09 2017 07:34 UTC
@Rushh I actually learned a lot about javascript with FCC
I haven't try Udemy or other codecamp, I tried codecademy a few years ago but didn't completed much
but maybe you're right that FCC is not for people who cannot study by themself
Mai Thinh
@mthinh
Jul 09 2017 07:34 UTC
I wonder if we could have a front end dev job after finishing front end section and getting the certificate?
Long Nguyen
@longnt80
Jul 09 2017 07:35 UTC
@mthinh no
not without real projects experience where you have to work with other team members
Luis
@zdrifted
Jul 09 2017 07:37 UTC
@longnt80 I could see someone who is a natural do well with FCC. I struggled terribly though but now I find it so much easier to visualize just from watching others code and following along
I'm a very visual learner though
Long Nguyen
@longnt80
Jul 09 2017 07:37 UTC
@Rushh yeah, different people need different methods
Mai Thinh
@mthinh
Jul 09 2017 07:38 UTC
@longnt80 im self-studying. Do you have any advice ? Can self-taught people get a job?
Long Nguyen
@longnt80
Jul 09 2017 07:38 UTC
@Rushh even when using FCC, I had to do a lot of research (stackoverflow, youtube, blogs) in order to understand
@mthinh I think getting a job got nothing to do with self-taught or learning from school
in both case, the person still has to learn a lot
even a person graduated from university can find it hard to get a job
Luis
@zdrifted
Jul 09 2017 07:41 UTC
True
Long Nguyen
@longnt80
Jul 09 2017 07:41 UTC
one thing for sure is don't expect to get a job easy if you just learning from some bootcamp for a few months or a year, even two years
the only people that can get jobs easily are experts who spent years mastering their craft
Luis
@zdrifted
Jul 09 2017 07:43 UTC
Yea and the boot camps that guarantee jobs have extremely low acceptance rates if they are legit
Long Nguyen
@longnt80
Jul 09 2017 07:47 UTC
I think your best bet is to find jobs from human connection
Getting to know people who can introduce you to a job
LiciniusRex
@hashtagyolo1
Jul 09 2017 07:50 UTC
I'm planning on starting with peopleperhour or some similar site to level up my experience once I've gotten comfortable with coding
Long Nguyen
@longnt80
Jul 09 2017 07:53 UTC
@hashtagyolo1 is that 1 on 1 tutoring?
Luis
@zdrifted
Jul 09 2017 07:56 UTC
Tutoring seems like a rip off. It's very expensive. I'd rather go through free tutorials and cheap courses. Plus there are free bootcamp prep courses you can take as well
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:10 UTC
@mthinh you can use a forEach method so far you're not returning any value in the callback
manuchehr94
@manuchehr94
Jul 09 2017 08:10 UTC
function truthCheck(collection, pre) {
  // Is everyone being true?
  var truthy = collection.every(function(obj) {
    for (var prop in obj) {
      return prop === pre;
    }
  });

  return truthy;
}

console.log(truthCheck([{
  "user": "Tinky-Winky",
  "sex": "male"
}, {
  "user": "Dipsy",
  "sex": "male"
}, {
  "user": "Laa-Laa",
  "sex": "female"
}, {
  "user": "Po",
  "sex": "female"
}], "sex"));
Hey, guys. Why is it checking only the first property?
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:14 UTC
@manuchehr94 because that's what the variable in for...in loop does, prop holds each key or property of the object per iteration
Manish Giri
@Manish-Giri
Jul 09 2017 08:16 UTC
@Lumexralph ggggggm :smiling_imp:
good morn
@manuchehr94 return prop === pre;
this means you want every prop in obj to be same as pre
the first prop it finds, it's user, so returns false
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:17 UTC
@Manish-Giri legendary sssggggggggggggggm :smiling_imp:
Manish Giri
@Manish-Giri
Jul 09 2017 08:17 UTC
lol :joy:
that's @joreyesl
manuchehr94
@manuchehr94
Jul 09 2017 08:17 UTC
@Manish-Giri @Lumexralph thanks
CamperBot
@camperbot
Jul 09 2017 08:17 UTC
:star2: 2025 | @lumexralph |http://www.freecodecamp.com/lumexralph
manuchehr94 sends brownie points to @manish-giri and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 6217 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:18 UTC
@Manish-Giri i'll eventually go deep into React or Angular JS libraries, just don't know why I love VanillaJS this much
Manish Giri
@Manish-Giri
Jul 09 2017 08:19 UTC
i'm kinda doing both at the moment
@Lumexralph
I've done React quite a bit, now learning angular 2
not sure which one I'll stick with
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:20 UTC
for now, my mind is made on React, if a project requires me to learn Angular, then i'll do that
i don't have time to touch surfaces alone
Manish Giri
@Manish-Giri
Jul 09 2017 08:21 UTC
high five :wave:
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:21 UTC
@Manish-Giri but that's why you're legendary
Manish Giri
@Manish-Giri
Jul 09 2017 08:22 UTC
lol
i iz a n00b
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 08:22 UTC
Can anyone help me ,
I have an array whose 5th element is also an array like [1,2,3,4,[1,2,3,4[ ] ] ]
how can i map over this array to create nested tags.
like for [1,2,3,4,[1,2,3,4[ ] ] ]
<MyComp>
     <MyComp>
     </MyComp>
</MyComp>
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:22 UTC
maybe when i'm comfy with React then I dive into Angular
just like it was very easy to go deep into Python when JS was deep enough, in the blood! :smile:
Manish Giri
@Manish-Giri
Jul 09 2017 08:23 UTC
@Lumexralph me in a few weeks
x
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:23 UTC
@Manish-Giri :joy: feel like that too.... but do I care? when I just love doing it
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 08:23 UTC
Any React Devs?
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:24 UTC
@Saikat-Sinha recursion and concat or join method might do the trick
@Manish-Giri how did you post the pic? you got it saved up somewhere on gitter?
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 08:26 UTC
@Lumexralph can u help me solving this using recursion? I am not that good with logics
Manish Giri
@Manish-Giri
Jul 09 2017 08:26 UTC
@Saikat-Sinha

render() {
let components = array[4].map(element => <li>{stuff}>/li>);
 return (
   <ul> 
     {components}
  </ul>
  )
}
@Lumexralph nope you can post any image in this format
![x](image URL)
um
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:28 UTC
don't mind me
i've to go bro! be good
@Saikat-Sinha @Manish-Giri is legend, he'll help you
Manish Giri
@Manish-Giri
Jul 09 2017 08:28 UTC
lol
pls
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:29 UTC
okay he's a NOOB
Manish Giri
@Manish-Giri
Jul 09 2017 08:29 UTC
:+1:
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:30 UTC
whatever ! :smirk: :wave:
Manish Giri
@Manish-Giri
Jul 09 2017 08:31 UTC
:wave:
Gokula Krishna
@AKX-X-32
Jul 09 2017 08:41 UTC
hey guys
makalohri
@makalohri
Jul 09 2017 09:56 UTC
@knrt10 thank you man
CamperBot
@camperbot
Jul 09 2017 09:56 UTC
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
:cookie: 452 | @knrt10 |http://www.freecodecamp.com/knrt10
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:08 UTC
https://codepen.io/CallMeJoe/pen/dRgGKz?editors=1011
Can you look into this bug? The same name repeats ...
Stephen James
@sjames1958gm
Jul 09 2017 11:10 UTC
@JoeTinnySpace This is because of the nature of closures. When the second ajax call happens, The for loop has run to completion and val holds the last user.
http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:12 UTC
@sjames1958gm thank you
CamperBot
@camperbot
Jul 09 2017 11:12 UTC
joetinnyspace sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8023 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 09 2017 11:13 UTC
@JoeTinnySpace :+1:
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:14 UTC
How long have you been learning?
Wadie
@wadie
Jul 09 2017 11:14 UTC
Any idea how to access a RSS feed while avoiding the whole cross site thing, because it's an external source
Stephen James
@sjames1958gm
Jul 09 2017 11:16 UTC
@JoeTinnySpace I have been working in javascript for a couple of years. Programming in general longer.
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:16 UTC
@sjames1958gm Aye Wise Captain
Wadie
@wadie
Jul 09 2017 11:17 UTC
lol
@sjames1958gm any idea ?
Stephen James
@sjames1958gm
Jul 09 2017 11:19 UTC
@wadie haven't work with any RSS feeds,sorry
Wadie
@wadie
Jul 09 2017 11:21 UTC
@sjames1958gm OAuth ?
Stephen James
@sjames1958gm
Jul 09 2017 11:23 UTC
I guess if you are authorized by the RSS source it should attach the cross site headers. I am only speculating
Wadie
@wadie
Jul 09 2017 11:26 UTC
It's an external source, can't play with the headers
so it's either RSS or authorizing with OAuth
Stephen James
@sjames1958gm
Jul 09 2017 11:30 UTC
Have you tried a library like rss-parser?
Wadie
@wadie
Jul 09 2017 11:32 UTC
I'll check it out, thx
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 11:32 UTC

Please help solving this:

makeTags(arr) {
        arr.map(ele=> {
            if(typeof ele === 'string') {
                var element = (<PostPanel></PostPanel>);
                return element;
                //console.log('<PostPanel></PostPanel>')
            } else { //This means its an array
                return this.makeTags(ele);
            }
        });
    }

here arr is [1,2,3,4,[ ]] which i want shoulg generate <PostPanel></PostPanel>
or if the arr is [1,2,3,4,[1,2,3,4,[ ] ]] it should generate

<PostPanel>
   <PostPanel></PostPanel>
</PostPanel>
Wadie
@wadie
Jul 09 2017 11:33 UTC
It's not clear what are you trying to achieve
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 11:34 UTC
@wadie i am trying to create facebook like comment system ..........check this https://gist.githubusercontent.com/Saikat-Sinha/257a2b69571afece9886f58ac0eaced7/raw/6fe4eeac929460adade9a93c49727080e6089e13/commentData.json
check the comment property
WAINGOR
@WAINGOR
Jul 09 2017 11:47 UTC
Hi all, I have a question on a page I'm currently building:
https://reparaties.brandfield.nl/
If you downsize the browser width you will see a hamburger menu icon appear. This icon has position:absolute, and its parent is position: relative. If you click around the bottom of the hamburger instead of the menu appearing, you will go to an URL... This URL is set on the brand logo on the top center of the page... Doe anybody know how to fix this?
ramarcinek
@ramarcinek
Jul 09 2017 11:52 UTC

Hello!

Can anyone help me with removing class "open" from let dropDownMenu?
It doesn't work - in chrome dev tools I can still see that that .open is assigned.

I've also tried removing the class with classList.remove("open") - but it aslo doesn't work

let burgerMenu = document.querySelector(".burger-menu");
let dropDownMenu = document.querySelector(".nav-list");

burgerMenu.addEventListener("click", function(){

if (dropDownMenu.classList != "open") {
    dropDownMenu.classList.toggle("open", true);
} else {
    dropDownMenu.classList.toggle("open", false);
}

});

Emmanx
@Emmanx
Jul 09 2017 11:55 UTC
Hello guys
I have a bit of a DOM issue
I have a bunch of buttons and I want to add a css class to the clicked one and remove it when another button is clicked so that only the currently clicked one has the class.
Alan Alickovic
@alan2207
Jul 09 2017 12:03 UTC
@Emmanx are you using jquery or plain javascript?
for plain javascript: button.classList.toggle('class')
for jquery: $( button ).toggleClass( "class" );
ramarcinek
@ramarcinek
Jul 09 2017 12:06 UTC
@alan2207 I seem to have similar problem. Could you please have a look at my code above?
Alan Alickovic
@alan2207
Jul 09 2017 12:08 UTC
@ramarcinek you do not have to check if your menu has class of open, by using toggle it will automatically switch on and off
try without conditions, just use toggle('open')
ramarcinek
@ramarcinek
Jul 09 2017 12:09 UTC
@alan2207 OK, I will try in a minute
@alan2207 Ok it works in 50%. How should I remove the class .open which was added after click event?
Alan Alickovic
@alan2207
Jul 09 2017 12:11 UTC
by clicking on it again, it will remove it if it is there, and add if it is not there
that is the point of toggle
ramarcinek
@ramarcinek
Jul 09 2017 12:12 UTC

@alan2207

let burgerMenu = document.querySelector(".burger-menu");
let dropDownMenu = document.querySelector(".nav-list");

burgerMenu.addEventListener("click", function(){
dropDownMenu.classList.toggle("open", true);
});

it doesn't work
Alan Alickovic
@alan2207
Jul 09 2017 12:12 UTC
remove true
ramarcinek
@ramarcinek
Jul 09 2017 12:12 UTC
Yeah :) it works! Thank you very much!
Alan Alickovic
@alan2207
Jul 09 2017 12:13 UTC
you are welcome :smile:
Joseph Joe
@JoeTinnySpace
Jul 09 2017 12:24 UTC
https://codepen.io/CallMeJoe/pen/dRgGKz?editors=0001
Why is that each streamer's links doesn't load? Is because of any exception?
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 12:25 UTC
is there any way to nest React componets
makeTags(arr) {
        const panel = arr.map(ele =>{
            var p = <PostPanel elem={ele}>{}</PostPanel>
            return (ele[4].length === 0)? p :p;
        });
        return panel;
    }
Arnish
@arnishg
Jul 09 2017 12:34 UTC
Hi Im stuck in the challenge where you have to return every first character of words of a string capitalised
here is my code
Screenshot (6).png
Stephen James
@sjames1958gm
Jul 09 2017 12:35 UTC
@Saikat-Sinha Why not have PostPanel decide whether to include the data from ele[4]?
John
@AnonymousLords
Jul 09 2017 12:35 UTC
@fmccroy i fixed that, and it still wrong :worried: thx anyways
CamperBot
@camperbot
Jul 09 2017 12:35 UTC
john-freecodecamp sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @fmccroy |http://www.freecodecamp.com/fmccroy
Stephen James
@sjames1958gm
Jul 09 2017 12:35 UTC
@arnishg You are only adding the first character to the result, you need to add the reset of each word.
John
@AnonymousLords
Jul 09 2017 12:36 UTC
.
Arnish
@arnishg
Jul 09 2017 12:36 UTC
Ohh, Got it @sjames1958gm thanks
CamperBot
@camperbot
Jul 09 2017 12:36 UTC
arnishg sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8024 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John
@AnonymousLords
Jul 09 2017 12:36 UTC
var myArray = [["John", 23], ["dog", 3]];
myArray.pop(["John", 23]);
myArray.unshift(["Paul", 35]);
Its still wrong it says @fmccroy , i might reset the challenge if its glitched https://www.freecodecamp.org/challenges/manipulate-arrays-with-unshift
Stephen James
@sjames1958gm
Jul 09 2017 12:38 UTC
@John-freeCodeCamp Are you supposed to remove the first or last entry? pop removes the last
John
@AnonymousLords
Jul 09 2017 12:38 UTC
OH
Stephen James
@sjames1958gm
Jul 09 2017 12:38 UTC
@John-freeCodeCamp You changed the line that said myArray.shift()
Moisés Man
@moigithub
Jul 09 2017 12:38 UTC
pop dont use any values. just arr.pop() @John-freeCodeCamp
John
@AnonymousLords
Jul 09 2017 12:39 UTC
Thanks @fmccroy @sjames1958gm @moigithub
CamperBot
@camperbot
Jul 09 2017 12:39 UTC
john-freecodecamp sends brownie points to @fmccroy and @sjames1958gm and @moigithub :sparkles: :thumbsup: :sparkles:
:warning: john-freecodecamp already gave fmccroy points
:star2: 8025 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3486 | @moigithub |http://www.freecodecamp.com/moigithub
Stephen James
@sjames1958gm
Jul 09 2017 12:39 UTC
@JoeTinnySpace Twitch always seems to give me fits when linking to it
@John-freeCodeCamp :+1:
judgejab
@judgejab
Jul 09 2017 13:00 UTC
Hey guys, can someone please tell me how I can limit how many times the group is matched?:
let repeatNum = "42 42 42";
let reRegex = /(\d+)\s\1\s\1/; // Change this line
let result = reRegex.test(repeatNum);
console.log(result);
It should only match the group 3 times
so "42 42 42 42" won't work
The above is the official solution in the docs but its still failing an assertion
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 13:03 UTC
@judgejab try adding ^ and $ to the regex.
judgejab
@judgejab
Jul 09 2017 13:04 UTC
Thank you! I tried the $ but didn't think of the ^ too, thanks @saifsmailbox98
CamperBot
@camperbot
Jul 09 2017 13:04 UTC
judgejab sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 740 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 13:05 UTC
@judgejab you need to add both as "42 42 42 42" will match if you only have $.
judgejab
@judgejab
Jul 09 2017 13:05 UTC
got it :)
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 13:06 UTC
@judgejab :+1:
Ken Haduch
@khaduch
Jul 09 2017 13:10 UTC
@judgejab - have you tried some of the regex learning sites like the
Getting Started Tutorial: http://regexone.com (FCC recommended)
RegEx 101: https://regex101.com
If you're new to regular expressions, they give some good lessons and interactive tools to see the effects of different regular expression operations.
teevik
@teevik
Jul 09 2017 13:12 UTC
@khaduch thanks, i have wanted to learn regex for so long
CamperBot
@camperbot
Jul 09 2017 13:12 UTC
teevik sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3084 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jul 09 2017 13:13 UTC
@teevik - you're welcome. Regular expressions can be tricky and can get complicated, but they have a lot of usefulness that makes them worth learning.
Sofus Heggemsens
@Sofeo
Jul 09 2017 13:18 UTC
hey any of you guys have some tips for the Chunky Monkey challenge?
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:18 UTC
@Sofeo .slice and Math
otherwise: while loop with 1 edge case in mind: a chunk of size 0
Ken Haduch
@khaduch
Jul 09 2017 13:20 UTC
@Sofeo - I would say a for loop with a loop count of i += size, and .slice...
Moisés Man
@moigithub
Jul 09 2017 13:21 UTC
slice manually.. find the correct indices.. then refactor with a loop @Sofeo
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:25 UTC
Mathematically, given a sequence of N items and an intended subsequence size of n, the number of subsequences of size n inside N is equal to Nn\lceil \frac{N}{n} \rceil
or Math.ceil(N/n)
then you can start a loop that goes from 0 to that number-1 and use it as an anchor for the slicing indices on every turn of the loop (involves more math and tinkering but you eventually get there)
but careful when n = 0, you need to guard against sizes <= 0
Sofus Heggemsens
@Sofeo
Jul 09 2017 13:35 UTC
@luishendrix92 can you exsplain that a little more simple?
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:36 UTC
I can't really explain the part where you actually slice and push the chunks since you gotta figure it your yourself
but what I can tell you is how to start if you want to take the math approach
imagine you have [1,2,3,4,5]
the length is 5, say you wanth the chunks to be of size 2
like I said, the number of chunks is determined by Math.ceil(list.length / chunkSize)
because you want to preserve the last item, .ceil will ignore the decimal and round it up to the nearest integer to the "top" (hence ceil)
5 / 2 = 2.5, ceiled = 3
which means you'll eventually get 3 chunks:
[1,2] [3,4] and [5]
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 13:38 UTC
The Math.ceil() function returns the smallest integer greater than or equal to a given number.
Math.ceil(2.5); // 3
Math.ceil(5); // 5
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:38 UTC
then you can start a loop that keeps track of the chunk number (starting from 0 up to 2 because of 3-1)
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 13:38 UTC
so your loop will run for i=0, i=1 and i=2, that is three times for three chunks
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:39 UTC
LOOP i=0 -> slice from 0 (inclusive) to 2 (non inclusive)
LOOP i=1 -> slice from 2 (inclusive) to 4 (non inclusive)
LOOP i=2 -> slice from 4 (inclusive) to 6 (non inclusive)
if you can find the pattern here, you're IN!
forther hints is solving it for you
Sofus Heggemsens
@Sofeo
Jul 09 2017 13:40 UTC
ok thanks for the help
@luishendrix92
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:40 UTC
.slice is failure safe so, slicing from 4 to 6 even if index 5 doesn't exist will yield just 1 item instead of [5, undefined]
luccifer00
@luccifer00
Jul 09 2017 14:10 UTC
Hi again! I continue no understanding why reverse geo locate dosent return the name of my city.

var gooloc ="https://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+long+"&key=AIzaSyBUzuWvyNu66-dU5DW8DfMqNQ87JgFPCUs&?results=address_components?";

$.getJSON(gooloc, function(loc){

var city = loc["long_name"]["administrative_area_level_2"];
var state = loc.adress_components["country"];
var province = loc.results.address_components["long_name"];

      $("#locate").html(city) 
The last part, its no working even it city, state, province, or "any text".
Stephen James
@sjames1958gm
Jul 09 2017 14:11 UTC
@luccifer00 &? seems wrong
luccifer00
@luccifer00
Jul 09 2017 14:12 UTC
I revise my json web is running, but i am not sure for the path...
@sjames1958gm anyways i tried before with the normal https ....
Mai Thinh
@mthinh
Jul 09 2017 14:14 UTC
how to compare with NaN pls ?
i want to compare like value !== NaN
how to do it ?
Stephen James
@sjames1958gm
Jul 09 2017 14:14 UTC
@mthinh nothing equals NaN even NaN
if value !== value then value is NaN
luccifer00
@luccifer00
Jul 09 2017 14:15 UTC
@sjames1958gm if u could take a look , here is my code pen https://codepen.io/luccifer00/pen/mwzmwa
Mai Thinh
@mthinh
Jul 09 2017 14:15 UTC
so how to use isNaN ?
Stephen James
@sjames1958gm
Jul 09 2017 14:17 UTC
@mthinh isNaN will return true for strings. You can use Number.isNaN more reliably
@luccifer00 remove those last two ? and see if you get better results
@luccifer00 You are going to have to dig into that returned json.
Mai Thinh
@mthinh
Jul 09 2017 14:25 UTC
@sjames1958gm thank you
CamperBot
@camperbot
Jul 09 2017 14:25 UTC
mthinh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8026 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kamal
@kpbro
Jul 09 2017 14:37 UTC
{"coord": {"lon":145.77,"lat":-16.92},
"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],
"base":"cmc stations",
"main":{"temp":293.25,"pressure":1019,"humidity":83,"temp_min":289.82,"temp_max":295.37},
"wind":{"speed":5.1,"deg":150},
"clouds":{"all":75},
"rain":{"3h":3},
"dt":1435658272,
"sys":{"type":1,"id":8166,"message":0.0166,"country":"AU","sunrise":1435610796,"sunset":1435650870},
"id":2172797,
"name":"Cairns",
"cod":200}
how do i select and use required weather data from above which is returned by weather api... can i use .propertyName ?
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:37 UTC
@kpbro What values do you intend to extract out of it?
Kamal
@kpbro
Jul 09 2017 14:37 UTC
like if it is a then a.weather or a.main?
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:38 UTC
right
Kamal
@kpbro
Jul 09 2017 14:38 UTC
all contents from main and wind
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:39 UTC
a.main.temp will give you 293.25
a.main.humidity will give you 83
and so on
Kamal
@kpbro
Jul 09 2017 14:39 UTC
oh.. i see and if i use only a.main what it will return?
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:39 UTC
a.main will be the entire object {"temp":293.25,"pressure":1019,"humidity":83,"temp_min":289.82,"temp_max":295.37}
Kamal
@kpbro
Jul 09 2017 14:40 UTC
i was guessing the same..
@SweetCodingInc i have just started local weather challenge. and i was testing if using that i can see temp. but it is not showing.
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:44 UTC
@kpbro do you have codepen for this?
if so, please share the link
Kamal
@kpbro
Jul 09 2017 14:44 UTC
yeah
Stephen James
@sjames1958gm
Jul 09 2017 14:46 UTC
@kpbro openweather API is only free over http, which you cannot use from https page. darksky API is one that is available over https
Kamal
@kpbro
Jul 09 2017 14:47 UTC
oh mann.. i didnt know that
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:48 UTC
yeah.. you need https and you also need to add &callback=? at the end of your url
@kpbro
Kamal
@kpbro
Jul 09 2017 14:48 UTC
why &callback= is needed?
&callback=?
Luc Martin
@fmartin5
Jul 09 2017 14:50 UTC
to tell jQuery it's a request for JSONP data
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:50 UTC
@kpbro to make cross domain ajax request
JSONP
Kamal
@kpbro
Jul 09 2017 14:51 UTC
fcc didnt teach any of these :worried:
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:58 UTC
That's for you to figure out :)
In real world, you won't be provided with all the instructions. You need to figure it out on your own as you go along
Kamal
@kpbro
Jul 09 2017 15:00 UTC
@SweetCodingInc yes.
Kamal
@kpbro
Jul 09 2017 15:11 UTC
@SweetCodingInc you still there?
need help on local weather challenge

https://codepen.io/kamalpancholi/pen/jwepBw?editors=0010

i have just started, so i am just testing to get data from api

Kamal
@kpbro
Jul 09 2017 15:17 UTC
this should show time zone of location instead of 'weather here' text
Moisés Man
@moigithub
Jul 09 2017 15:19 UTC
@kpbro open ur BROWSER devtools(F12 on most browsers) /console tab and check if u have any errors
getCurrentPosition is async means results will be returned later...
soo when u call getJSON .. those variables u using (lat,lon) are NOT populated yet.. they dont have any values
u can easily check that using console.log("lat,lon are ",lat,lon) before ur getJSON
Kamal
@kpbro
Jul 09 2017 15:23 UTC

api.darksky.net/forecast/408427c870a2486ac6902cd8f6bacd3d/,&callback=jQuery32105659435922683238_1499613084762?_=1499613084763

i got error. api url doesnt have latitude and longitude..
@moigithub

:point_up: July 9, 2017 8:53 PM got this from console
Moisés Man
@moigithub
Jul 09 2017 15:25 UTC
RE.read above....
Kamal
@kpbro
Jul 09 2017 15:25 UTC
@moigithub what i can do about this ?
yea. i read it. what should i do?
Moisés Man
@moigithub
Jul 09 2017 15:26 UTC
ur getJSON uses lat and lon values.. where do u have those values available ??
in other words.. move ur getJSON code inside getCurrentPosition callback
Kamal
@kpbro
Jul 09 2017 15:28 UTC
@moigithub yes.. got it
@moigithub but i have assigned lat and lon values to those variables inside getCurentPosition. Why it is not working
Moisés Man
@moigithub
Jul 09 2017 15:31 UTC
cuz async ?? (explained above)
Kamal
@kpbro
Jul 09 2017 15:31 UTC
yes..
iam clear now
schizo99
@shashank1999coder
Jul 09 2017 15:38 UTC

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

function myObj(checkProp) {
// Your Code Here
return (myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : "Not Found");
}

// Test your code by modifying these values
myObj("gift");
guys its not working plz help

hey guys can anybody help me
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:43 UTC
@shashank1999coder check the name of your object and function
@shashank1999coder the interpreter picked the name of your function so using myObj and trying to access the hasOwnProperty method will return a TypeError, since it recognizes myObj but it doesn't have that method, so it can't perform that action. change the name of your function to something other than myObj
@shashank1999coder FCC gave the function another name
schizo99
@shashank1999coder
Jul 09 2017 15:47 UTC

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkprop"))
return myObj[checkProp];

return "NotFound";

}
// Test your code by modifying these values
myObj("gift");

tried this one too not yet working
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:47 UTC
@shashank1999coder how did you call the function? myObj("gift");
@shashank1999coder
function checkObj(checkProp) {
// Your Code Here
return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : "Not Found";
}
// Test your code by modifying these values
checkObj("gift");
@shashank1999coder what you did initially will work, just change the function name, it's conflicting with the object name
schizo99
@shashank1999coder
Jul 09 2017 15:49 UTC
@Lumexralph i have corrected myObj("gift")
but i not showing result for "gift"
rather its showing "Not Found" in result
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:51 UTC
show your code
schizo99
@shashank1999coder
Jul 09 2017 15:51 UTC

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkprop"))
return myObj[checkProp];

return "Not Found";

}
// Test your code by modifying these values
checkObj("gift");

Ogundele Olumide
@Lumexralph
Jul 09 2017 15:51 UTC
@shashank1999coder the initial code you had, post it
@shashank1999coder checkProp is a parameter and not a string
@shashank1999coder if (myObj.hasOwnProperty(checkProp))
schizo99
@shashank1999coder
Jul 09 2017 15:52 UTC
thank you @Lumexralph
CamperBot
@camperbot
Jul 09 2017 15:52 UTC
shashank1999coder sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2026 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:52 UTC
@shashank1999coder but I still like the one you did using ternary operator
schizo99
@shashank1999coder
Jul 09 2017 15:53 UTC
@Lumexralph hmm
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:53 UTC
@shashank1999coder this
function checkObj(checkProp) {
// Your Code Here
return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : "Not Found";
}
// Test your code by modifying these values
checkObj("gift");
schizo99
@shashank1999coder
Jul 09 2017 15:54 UTC
yaa
Kelechi Chinaka
@ke1echi
Jul 09 2017 15:59 UTC
:wave: guys
@Lumexralph awfa baba
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:01 UTC
@kelechy Brotherly, I'm good, you?
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:02 UTC
fine @Lumexralph what are u currently working on
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:08 UTC
@kelechy not much, finally have the motivation to finish that eloquent js palava, want to start my pomodoro but want to use OOP and then maybe read a book on functional programming in the process and I hope I submitted my assessment this time around
@kelechy so you had to still click on submit assessment even when you had completed each challenge?
Eva Raymond
@elitenoire
Jul 09 2017 16:09 UTC
function convertObjectToList(obj) {
  // your code here
  var keyList = Object.keys(obj);
  // var array = [];
  // for(var i=0; i < keyList.length;i++){
  //   array.push([keyList[i],obj[keyList[i]]]);
  // }
  // return array;
  return keyList.reduce((list,key)=> list.push([key, obj[key]]),[])
}
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:09 UTC
ok..nice ..books helps too @Lumexralph
yes i think so @Lumexralph
Eva Raymond
@elitenoire
Jul 09 2017 16:10 UTC
someone help me keep getting error of can't read push property of undefined
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:12 UTC
@Lumexralph i need to learn OOP
Stephen James
@sjames1958gm
Jul 09 2017 16:12 UTC
@elitenoire you need to return list from the anonymous function
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:13 UTC
@elitenoire because push returns the length of the array
Eva Raymond
@elitenoire
Jul 09 2017 16:14 UTC
it worked!!!
thanks, thought I tried that earlier but didn't work.
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:15 UTC
@kelechy then go ahead, there's not much biggy, just understanding the reason for it and the concept
@sjames1958gm Chelsea lost out on Lukaku and I was shocked
Eva Raymond
@elitenoire
Jul 09 2017 16:16 UTC
i'm gradually getting the hang on using the reduce method
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:16 UTC
@elitenoire cool
Stephen James
@sjames1958gm
Jul 09 2017 16:19 UTC
@Lumexralph Yeah. been a crazy off season
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:19 UTC
class Person {
  // Get coding in ES6 :D
  constructor (firstName = "John", lastName = "Doe", age = 0, gender = "Male") {
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    this.gender = gender;
  }
    sayFullName() { return this.firstName + ' ' + this.lastName }

    greetExtraTerrestrials (raceName) {
      return "Welcome to Planet Earth " + this.raceName;
    }
}
TypeError: Person.greetExtraTerrestrials is not a function
how do i define a working class method
Moisés Man
@moigithub
Jul 09 2017 16:20 UTC
create a instance of person first...?
var bob = new Person()
bob.greet........()
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:21 UTC
@sjames1958gm and Conte is going ballistic
aRtoo
@artoodeeto
Jul 09 2017 16:24 UTC
hi guys. i have a question. how do you change a part of a url using a button?? lets say www.weather.com/fahrenheit change to www.weather.com/celcius
i have this code its not much because i have no idea. i googled and stackedoverflow and i get nothing.
//changing button to Fahrenheit or Celsius
    //change also the text of the btn according to unit
    function changeUnit(){
      $('.btn').on('click', function(){
           //change the URL units
      })
    }
Stephen James
@sjames1958gm
Jul 09 2017 16:24 UTC
@artoodeeto just rebuild the URL string. create it from parts then exchange this part
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:25 UTC
ok @moigithub
aRtoo
@artoodeeto
Jul 09 2017 16:25 UTC
@sjames1958gm hmm. right. let me try.
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:26 UTC
@kelechy all this Class stuff JS is doing to please Class-oriented programming language developers
Dan Couper
@DanCouper
Jul 09 2017 16:26 UTC
That's basically every widely-used language to be fair though
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:27 UTC
@DanCouper no argument about that
Dan Couper
@DanCouper
Jul 09 2017 16:27 UTC
  • better than the 1001 various class pattern boilerplate crap that came before. 😊
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:28 UTC
@DanCouper i just kind of laugh a lil bit when I see Class keyword in JS programs
@DanCouper sure
Stephane
@overmelo
Jul 09 2017 16:29 UTC

hi, can someone tell me what's the difference between:

if(name===contacts[d].firstName){

      if(contacts[d].hasOwnProperty(prop)){

        return contacts[d][prop];

and

if(name ===contacts[d].firstName && contacts[d].hasOwnProperty(prop)){
return contacts[d][prop]
}
Dan Couper
@DanCouper
Jul 09 2017 16:29 UTC
Second one is shorter
First one is useful
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:30 UTC
yea..for a prototypal language, the idea of classes in js is really confusing too @Lumexralph
Stephane
@overmelo
Jul 09 2017 16:30 UTC
why am i not having the same result? @DanCouper
Dan Couper
@DanCouper
Jul 09 2017 16:30 UTC
If there's an else do something else on the inner loop
I don't know, you need to post more code, can't tell out of context
Stephane
@overmelo
Jul 09 2017 16:31 UTC
for(var d=0; d<contacts.length; d++){

    if(name===contacts[d].firstName){

      if(contacts[d].hasOwnProperty(prop)){

        return contacts[d][prop];
    } 
      else if(name!==contacts[d].firstName){

        return "No such contact";
      }

      else if(prop!==contacts[d].hasOwnProperty(prop))

      return "No such property";
    }
  }

// Only change code above this line
}
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:32 UTC
@kelechy but I think it's good for convention though
Dan Couper
@DanCouper
Jul 09 2017 16:32 UTC
this.raceName isn't a thing
@kelechy
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:33 UTC
class Person {
  // Get coding in ES6 :D
  constructor (firstName = "John", lastName = "Doe", age = 0, gender = "Male") {
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    this.gender = gender;
  }
    sayFullName() { return this.firstName + ' ' + this.lastName }

    greetExtraTerrestrials (raceName) {
      return "Welcome to Planet Earth " + this.raceName
    }
}
var bob = new Person();
bob.greetExtraTerrestrials('date')
still dont get the idea and doesnt work @moigithub
:wave: @DanCouper
Dan Couper
@DanCouper
Jul 09 2017 16:33 UTC
That's not the issue tho, I can't see why that shouldn't work but on phone so bit difficult to debug
Stephane
@overmelo
Jul 09 2017 16:33 UTC
my code isn't working yet maybe you guys have a hint
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:34 UTC
@kelechy when you constructed your Class Person raceName was not a property
Stephane
@overmelo
Jul 09 2017 16:35 UTC
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(name, prop){
// Only change code below this line
  for(var d=0; d<contacts.length; d++){

    if(name===contacts[d].firstName){

      if(contacts[d].hasOwnProperty(prop)){

        return contacts[d][prop];
    } 
      else if(name!==contacts[d].firstName){

        return "No such contact";
      }

      else if(prop!==contacts[d].hasOwnProperty(prop))

      return "No such property";
    }
  }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
that's all
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:35 UTC
@kelechy when you created the instance raceName was also not a property in the instance bob

@overmelo

Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed

1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
@kelechy
var bob = new Person();
bob.raceName = "date";
bob.greetExtraTerrestrials(); //'Welcome to Planet Earth date'
@kelechy or
sayFullName() { return this.firstName + ' ' + this.lastName }

    greetExtraTerrestrials (raceName) {
      return "Welcome to Planet Earth " + raceName
    }
}
var bob = new Person();
//bob.raceName = "date";
bob.greetExtraTerrestrials("date");  //'Welcome to Planet Earth date'
Dan Couper
@DanCouper
Jul 09 2017 16:39 UTC
or
class Person {
  constructor(
    firstName = 'John',
    lastName = 'Doe',
    age = 0,
    gender = 'Male',
    raceName = 'Human'
  ) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    this.gender = gender;
    this.raceName = raceName;
  }
  sayFullName() {
    return this.firstName + ' ' + this.lastName;
  }
  greetExtraTerrestrials(raceName) {
    return 'Welcome to Planet Earth ' + this.raceName;
  }
}
Stephane
@overmelo
Jul 09 2017 16:39 UTC
@Lumexralph thanks, i will try to figure this out
CamperBot
@camperbot
Jul 09 2017 16:39 UTC
overmelo sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2027 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:41 UTC

@DanCouper @kelechy or

That's all!!

:smile:

Dan Couper
@DanCouper
Jul 09 2017 16:47 UTC
😊
Kelechi Chinaka
@ke1echi
Jul 09 2017 16:48 UTC
lol
aRtoo
@artoodeeto
Jul 09 2017 17:22 UTC
how do i get the normal time. not my local time. i have a parameters on my codes. but its not returning the right values. instead its returning my local time.
var date = new Date();
        var hours = date.getUTCHours(data.sys.sunrise);
        var minutes = date.getUTCMinutes(data.sys.sunrise);
        console.log(hours + 'hrs'); //testing
        console.log(minutes + 'min'); //testing
Mai Thinh
@mthinh
Jul 09 2017 17:39 UTC
i got frozen browser because of infinite loop
how can i fix it? pls help
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:40 UTC
Is the only way to pull a specific object from a json array, is to go through a for loop? What happens when you have 1000s or 1000000s of objects in the json array? Does it just take a long time to get output?
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (c = 0; c < contacts.length; c++) {
    if (contacts[c].firstName === firstName) {
      if (contacts[c].hasOwnProperty(prop)) {
        return contacts[c][prop];
      }
      else {
        return "No such property";
      }
    }
  }
  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
That’s the code but I’d think there was some better way to pull a specific object based on the properly without a loop that could take a long time to run. Thoughts?
alpox
@alpox
Jul 09 2017 17:47 UTC
@nsuchy No there is not. You do have to test each object to see if it fits your requirements. The same has to be done in databases - but they can create indices which make the lookup faster.
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:49 UTC
Oh, wasn’t sure, when I was doing the challenge and reading the hints, I was thinking it much be inefficient. I get that databases are a bit faster, but having to do a for loop with a bunch of checks to determine the number of the object, i wish there was like a search function or something to quickly find the object without writing out a loop. Loops have been one of the harder things for me to learn about.
alpox
@alpox
Jul 09 2017 17:49 UTC
In your case your best bet is to do what you did - loop over them all.
If you really would want to speed up the lookup if the amount was huge, would be to create in-memory indices for your data - and/or in some cases to sort your data in memory
@nsuchy Well you could use implicit loops - but that doesn't make it faster, rather slower

@nsuchy My solution:

function lookUp(firstName, prop){
  var contact = contacts.find(function(c) { return c.firstName === firstName; });
  if(!contact) return "No such contact";
  return contact[prop] || "No such property";
}

Its just easier to read / more efficient to write, but its not faster in any way regarding execution time

Nathaniel Suchy
@nsuchy
Jul 09 2017 17:52 UTC
It’s a matter of both speed and ease of writing the code, imagine if each object has like 50 different properties, writing out that kinda loop with IF statements has got to be messy, has the industry found a solution yet, or is a lot of time spent on writing out those loops?
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:52 UTC
@alpox do you think find won't do a form of looping ?
alpox
@alpox
Jul 09 2017 17:53 UTC
@Lumexralph As i said, it DOES loop ;-) you cannot come around that here
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:53 UTC
@alpox :laughing:
alpox
@alpox
Jul 09 2017 17:54 UTC
@nsuchy Well you would usually go with abstracted methods for looping like .find as i did
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:54 UTC
Ok
alpox
@alpox
Jul 09 2017 17:54 UTC
@nsuchy I use direct loops like for loops almost never
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:54 UTC
Also:

function randomFraction() {

  // Only change code below this line.

  var x = 0;
  while (x === 0) {
    x = Math.random();
  }
  return x;

  // Only change code above this line.
}
alpox
@alpox
Jul 09 2017 17:54 UTC
Just in a few cases where they really make sense
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:54 UTC
@alpox was just thinking about what @nsuchy said, maybe there'll be better algorithms though
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:54 UTC
Does that code prevent the number from ever being 0? (E.g. the code keeps running until it’s not 0?)
alpox
@alpox
Jul 09 2017 17:55 UTC
@Lumexralph I'm open to suggestions :D
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:55 UTC
@Lumexralph That’s what I’m asking, if we’ve found a better solution than looping through objects, large json objects are going to be my new nightmares.
Thanks @Lumexralph @alpox
CamperBot
@camperbot
Jul 09 2017 17:55 UTC
nsuchy sends brownie points to @lumexralph and @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1247 | @alpox |http://www.freecodecamp.com/alpox
:star2: 2028 | @lumexralph |http://www.freecodecamp.com/lumexralph
alpox
@alpox
Jul 09 2017 17:55 UTC
@nsuchy Yes, the while loop runs as long as x is zero and cannot be left until thats not true anymore
So when you leave the while, x MUST be !== 0
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:56 UTC
@alpox i know there'll be some mathematicians would've cooked up some stuffs
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:56 UTC
Ok, it worked, I just wanted to make sure my code was correct and the while loop was working as intended, I never want the number to be zero.
alpox
@alpox
Jul 09 2017 17:56 UTC
@Lumexralph Thats not about maths. Its about logic :D I attended advanced database lessons recently with query-optimization stuff etc. and they said in such cases there is no better way (As long as you don't have an index or especially sorted data)
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:57 UTC
@alpox hmmm..... interesting
alpox
@alpox
Jul 09 2017 17:57 UTC
Ofc. your lookup will be damn fast when you use a Hashindex or a B+ Tree
A Hashindex gets very slow though if you run range queries
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 17:58 UTC
Hey guys i am stuck at this challenge - Iterate through an array with a for loop.
Nathaniel Suchy
@nsuchy
Jul 09 2017 17:58 UTC
@alpox Prefereably I’d be able to pull all objects with the same value in a specific property, though if I get two objects because they have the same property, I once again have to loop through those until I find the right one. It might save some time but in other cases make the code take even longer to run
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:58 UTC
@alpox enlightening, is B+ also binary search ?
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 17:58 UTC
I am having problem in understanding the logic behind the length property = -1.
Ogundele Olumide
@Lumexralph
Jul 09 2017 17:59 UTC
@KsangwanA your question is not clear
alpox
@alpox
Jul 09 2017 17:59 UTC
@Lumexralph No. Binary search only makes sense in very few cases. 1. Requirement: sorted data. 2. requirement: sorted data can be transformed to equi-spaced numbers
Ogundele Olumide
@Lumexralph
Jul 09 2017 18:00 UTC
@alpox cool, just wanted be cleared
@alpox thanks
CamperBot
@camperbot
Jul 09 2017 18:00 UTC
lumexralph sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1248 | @alpox |http://www.freecodecamp.com/alpox
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:00 UTC
@Lumexralph
Frank McCroy
@fmccroy
Jul 09 2017 18:02 UTC
@KsangwanA Are you talking about looping through an array and needing to stop at array.length-1 ? Arrays start at 0, whereas counting for length starts at 1. An array with length of 5 is really array[0], [1], [2],[3],[4] not array[5], which is how you get length-1.
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:02 UTC
If you go to the challenge you'll see. I cannot understand the zero - based numbering system according to which the last index of the array is length -1.
alpox
@alpox
Jul 09 2017 18:03 UTC
@Lumexralph B+ indexes are special memory-trees with nodes on several tree levels - where each node holds a number of pointers/value pairs. The values are only values from one property of the data and sorted in the index/nodes. The values in the nodes indicate some kind of datastep where if the value you are looking for is lower than the value you see in the current node index, you have to go left down the tree, else you have to go right through the pointer/value pairs and follow the pointer to the next value if the value you are looking for is smaller than the value indicated in the node.
The B+ tree is always balanced too
Its quite some effort to build it :-)
But it pays out and is very often used in databases. Its a self-balancing multi-level memory-index which makes it very strong
Ogundele Olumide
@Lumexralph
Jul 09 2017 18:04 UTC
@alpox special memory-trees with nodes on several tree levels more like DOM tree
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:05 UTC
@ Frank McCroy I still don't get it. Can you please give an example.
alpox
@alpox
Jul 09 2017 18:06 UTC
@Lumexralph Hmm not really. Well, sure the DOM is also a tree, but there are very different kinds of trees which serve very different purpose :D
Ogundele Olumide
@Lumexralph
Jul 09 2017 18:07 UTC
@alpox just painting an analogy :wink:
Frank McCroy
@fmccroy
Jul 09 2017 18:09 UTC
var arr = [“a”, “b”, “c”, “d”];
for (i=0; i <= arr.length-1; i++){
console.log(“Position “ + i + “ is value “ + arr[i]);}
So the length of arr is 4, but to loop through it you get arr[0], arr[1], arr[2], arr[3] and then you stop. That shows your 4 values of arr.
Alexander Køpke
@alexanderkopke
Jul 09 2017 18:09 UTC
@KsangwanA var array = ["test", "hi", "bye"]. array.length is 3. to access "bye" I will have to do array[2]. 2 is 3 - 1. Or length - 1... so I can do array[array.length - 1] and I will get "bye"
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:11 UTC
Can anyone tell me how can I change the html elements values from routes files in nodejs?
Frank McCroy
@fmccroy
Jul 09 2017 18:15 UTC
@Gurpreet3131 Definetely not me, I have no idea what you are asking or are trying to do.
Vishal Nagda
@vishalnagda1
Jul 09 2017 18:16 UTC

Hello everyone!!!
Currently I’m working on this exercise.
So, as a solution for my problem I wrote the following code :
```function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(index){
return !isNaN(index) && index !== false && index !== null && index !== 0 && index !== "" && index !== undefined;
});
}

bouncer([7, "ate", "", false, 9]);```
which is not working as I want.
Can anyone here explain me why is it not working ?

Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:16 UTC
Ookkk now i get it .
Ogundele Olumide
@Lumexralph
Jul 09 2017 18:16 UTC
@vishalnagda1 !isNaN(index)
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:17 UTC
@fmccroy thanks
CamperBot
@camperbot
Jul 09 2017 18:17 UTC
ksangwana sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @fmccroy |http://www.freecodecamp.com/fmccroy
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:17 UTC
@Gurpreet3131 I am not sure but try pug.
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:17 UTC
@
Vishal Nagda
@vishalnagda1
Jul 09 2017 18:17 UTC
Yes because of the !isNaNbut why ?
Moisés Man
@moigithub
Jul 09 2017 18:17 UTC
@Gurpreet3131 use a template system like pug/handlebars/ejs
Ashish Kumar Sangwan
@KsangwanA
Jul 09 2017 18:17 UTC
@alexanderkopke thanks.
CamperBot
@camperbot
Jul 09 2017 18:17 UTC
ksangwana sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1602 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:20 UTC
@fmccroy
I have a <p> tag in html file. layout.handlebars. I am using expressjs. So now, I want to change the contents of this <p> tag from a routes file
@moigithub can you tell me how to do it, I am new to this
Ogundele Olumide
@Lumexralph
Jul 09 2017 18:20 UTC
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:20 UTC
@Gurpreet3131 do you want to change the content based on what URL is requested?
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:21 UTC
yes
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:21 UTC
@Gurpreet3131 try https://github.com/tj/ejs, you can manipulate the template with props on request query.
Vishal Nagda
@vishalnagda1
Jul 09 2017 18:21 UTC
@Lumexralph thank you :)
CamperBot
@camperbot
Jul 09 2017 18:21 UTC
vishalnagda1 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2029 | @lumexralph |http://www.freecodecamp.com/lumexralph
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:22 UTC
@saifsmailbox98 Well, I am redirecting everything request to a model file, which change the value of p tag after fetching data from database
Moisés Man
@moigithub
Jul 09 2017 18:22 UTC
@Gurpreet3131 u can check on youtube :P there are many videos
node + pug
node + ejs
node + handlebars
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:23 UTC
@moigithub can you give me a brief prview of what ejs or pug will do?
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:23 UTC
also there is a getting started guide on ejs here http://ejs.co/
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:25 UTC
I will have a look at it
Moisés Man
@moigithub
Jul 09 2017 18:26 UTC
https://www.youtube.com/watch?v=notmWXm3yf8 3min video
there are longers videos too.. u just need to SEARCH on youtube.. many similars @Gurpreet3131
Hello911
@Hello911
Jul 09 2017 18:26 UTC
.glass.down{
  transform: translateY(100%) translateY(-5em);
}
I know .glass is a HTML class. and .down is another class. but Why are they separated by a PERIOD not a COMMA? Is down here referring to .down class? also, Why 2 translateY?
Alexander Køpke
@alexanderkopke
Jul 09 2017 18:28 UTC
wow did ejs update their site or is it a new one?
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:35 UTC
@saifsmailbox98 I @moigithub I think you misunderstood by question, I am using handlebars view engine and I have a template file called layout.handlebars. What I want to do is, change the value of a <p> tag from my routes files,
since document.getElementById(id).innerHTML = "abc"; is not working, what else can I use??
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:39 UTC
@Gurpreet3131 why don't you put the p tag as <p>{{content}}</p> and then pass the content's value from the route file.
response.render("layout",{ content : "abc"} );
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 18:48 UTC
Guys I need help,
I want to re render React component whenever my LocalStorage Changes .
what should be my approach?
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:49 UTC
@saifsmailbox98
res.render('index', {views: "any index value"});
this is what I tried and its not working
not sure why
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:50 UTC
@Gurpreet3131 is the file name index.handlebars? and are there any component in that file with {{views}}?
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:50 UTC
No, it is layout.handlebars
actually the tempate is layout.handlerbars and the body it obtained from other files
like index.handlebars, main.hbs etc
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 18:51 UTC
@Gurpreet3131 create a <p> tag with <p>{{content}}</p>, in your layout file.
Gurpreet SIngh
@Gurpreet3131
Jul 09 2017 18:52 UTC
I have created it
AlliBun
@AlliBun
Jul 09 2017 18:52 UTC
https://codepen.io/Erynfi/pen/PjdxKW
the switch case to change the background does not seem to work :c
Gulsvi
@gulsvi
Jul 09 2017 18:57 UTC
@AlliBun We can't compare arrays like [1000,1] == [1000,1], so you have to convert it to a string:
    weathercode = weathercode.toString();
    switch (weathercode) {
        case '1000,1': //sunny day
            background = 'https://photos-5.dropbox.com/t/2/AACLQzhNuU0ECNpAzLaldaSZM4brTNG4ezzenHgElliOQQ/12/683728763/jpeg/32x32/1/_/1/2/sunny%60.jpg/EOK_4s0FGNsHIAIoAg/oIgE_a6RWTLWIyfB9oqXwEGQ-SqSaquQ4vA0XmK5-5E?size=1280x960&size_mode=3';
            break;
Try using an object instead of using a switch statement - it will make this part of your code cleaner and easier to manage
Kevin
@kevinwr
Jul 09 2017 18:59 UTC
Anyone know which editors have a live load/preview feature, besides brackets? Besides that, do you know if brackets has a plugin to edit several occurrences of a tag,variable, etc?; I've found myself in several situations where I have several variables or tags in a document that I either want to change the name of at the same time without having to try to find each occurrence and change it, or delete a tag without affecting the inner content.
AlliBun
@AlliBun
Jul 09 2017 19:00 UTC
thank you so much @SkyC0der
CamperBot
@camperbot
Jul 09 2017 19:00 UTC
allibun sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2028 | @skyc0der |http://www.freecodecamp.com/skyc0der
Alexander Køpke
@alexanderkopke
Jul 09 2017 19:06 UTC
@kevinwr I think there is a find and replace feature in brackets too so you can find all variables and replace it with a different name. I don't know of other editors that have live load. I use lite-server which uses browser-sync. I don't know if you're using node though.
Thayyeb salim
@Thayyebsalim
Jul 09 2017 19:20 UTC
Thanks @saifsmailbox98
CamperBot
@camperbot
Jul 09 2017 19:20 UTC
thayyebsalim sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 741 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 19:20 UTC
@Thayyebsalim :+1: yw
Innocent Tauzeni
@Telthem89
Jul 09 2017 19:22 UTC
heloo
heelo am dowing my Use the Twitchtv JSON API help
sorry guys i need help on my Use the Twitchtv JSON API ....i dont get it can someone explain for me
Hello911
@Hello911
Jul 09 2017 19:47 UTC
@Hello911
image.png
How to make a rectangle into a arrow shape just using CSS code?
Moisés Man
@moigithub
Jul 09 2017 19:52 UTC
i think u would need 2 divs at least
rotate one (on top)
then "paint" the right borders
Hello911
@Hello911
Jul 09 2017 19:53 UTC
@moigithub I was thinking of building a pentagon using CSS
Jemal Mohammed
@JemalMoha
Jul 09 2017 19:54 UTC
hello All , could some one help on this String reverse...

function reverseString(str) {
//console.log(str);
var str1 = [];
var str2 = [];
for (var i = 0; i < str.length; i++) {
str1.push(str[i]);
}
console.log(str1);
for (var i = 0; i < str1.length; i++) {
str2[i] = str1.pop();
}
console.log(str2);
};

console.log(reverseString("hello"));

bilaal-s
@bilaal-s
Jul 09 2017 19:55 UTC

@moigithub yes it squares it, sorry for late reply

Math.Pow(nextSquare, 2); what this line does ??
does it changes the value of nextSquare ?? @bilaal-s

Manish Giri
@Manish-Giri
Jul 09 2017 19:55 UTC
@JemalMoha you can just split a string into an array and reverse it, then join it back..
Moisés Man
@moigithub
Jul 09 2017 19:56 UTC

...does it mutates/changes the variable nextSquare ? @bilaal-s
is similar to this

a=1;
a+1  //<< does it changes a value?? (answer is NOPE :) )

unless u do a= a + 1

Jemal Mohammed
@JemalMoha
Jul 09 2017 19:58 UTC
@Manish-Giri ok, but what do ypu think us missing the code not to work
John
@AnonymousLords
Jul 09 2017 19:59 UTC
:point_up: July 9, 2017 8:39 AM @sjames1958gm :thumbsup:
Jemal Mohammed
@JemalMoha
Jul 09 2017 19:59 UTC
it is printio o,l,l
Manish Giri
@Manish-Giri
Jul 09 2017 20:02 UTC
@JemalMoha it's because str1.pop()also changes the length of the str1 array
and if you do i < str1.length, it will only continue the loop as long as this condition is true
look at the console logs
in every iteration of the loop, i increases and str1.length decreases, until the time when i < str1.length is no longer true
Jemal Mohammed
@JemalMoha
Jul 09 2017 20:05 UTC
great , it makes sense!
@Manish-Giri thank you!
CamperBot
@camperbot
Jul 09 2017 20:06 UTC
jemalmoha sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6218 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jul 09 2017 20:06 UTC
:+1:
aRtoo
@artoodeeto
Jul 09 2017 20:08 UTC

hi guys. i have a div tex and button. how can i put them side by side??
i have this code:

<div class="row">
          <div class="col-md-12 parent-temp">
            <h3>  TEMPERATURE  </h3>

                <div class="row temp_img">

                  <div class="col-md-1 col-md-offset-5">
                  <div id="temperature" class="disp_temp "></div>
                  <button class="btn btn-default col-md-1">F</button>
                  </div>

                  <div class="col-md-1">
                    <img id="icon_img" class="" src="#" alt="weather_icon" >
                  </div>
                </div>
          </div>
        </div>

heres the codepen:
https://codepen.io/artoo/pen/bRmrzz

John
@AnonymousLords
Jul 09 2017 20:12 UTC
@artoodeeto What are you putting next to each other? saying "Div tex and button" is a litte confusing
aRtoo
@artoodeeto
Jul 09 2017 20:13 UTC
@John-freeCodeCamp the button sir. i want close to the 122
@John-freeCodeCamp its under the text.
John
@AnonymousLords
Jul 09 2017 20:13 UTC
So next to each other?
122 and the button next to each other?
Try giving it its own row
Greta Piliponytė
@gpiliponyte
Jul 09 2017 20:16 UTC
Hello
John
@AnonymousLords
Jul 09 2017 20:16 UTC
You did the whole row thing weird
Dovydas Stirpeika
@Giveback007
Jul 09 2017 20:16 UTC
hey peeps do you guys know anything about ios safari browser compatability?
John
@AnonymousLords
Jul 09 2017 20:16 UTC
Each should have its own div with "col-md-6" or something
Dovydas Stirpeika
@Giveback007
Jul 09 2017 20:16 UTC
and it's driving me crazy
John
@AnonymousLords
Jul 09 2017 20:17 UTC
@artoodeeto This is a example of how you should use the row feature
This message was deleted
Dovydas Stirpeika
@Giveback007
Jul 09 2017 20:17 UTC
the header doesn't obey 100vw and heigh on ios devices
John
@AnonymousLords
Jul 09 2017 20:18 UTC
  <div class="row">
    <div class="col-md-8 text-center">
      <div class="block2 borderexample">
        <h2 class="h2-secondpage text-center">John Nicole</h2>
        <hr>
        <p>Hello</p>
      </div>
    </div>
    <div class="col-md-4">
      <img class="img-fer" src="https://s7.postimg.org/7xz09h0yz/image-3.jpg" alt="Ferrari ill never be able to afford.">
      <h3 class="block3 borderexample">I love Ferrari's and Lamborghini's.</h2>
      </div>
  </div>
</div>
@artoodeeto See each thing has its own "col-md-_" div? and its all under one big row div.
aRtoo
@artoodeeto
Jul 09 2017 20:19 UTC
@John-freeCodeCamp yea i have that. one big row
John
@AnonymousLords
Jul 09 2017 20:20 UTC
Now does it all equal up to 12?
aRtoo
@artoodeeto
Jul 09 2017 20:20 UTC
@John-freeCodeCamp yea. wait. send it to you
John
@AnonymousLords
Jul 09 2017 20:20 UTC
Its a total of 13
aRtoo
@artoodeeto
Jul 09 2017 20:20 UTC
@John-freeCodeCamp
    <div class="row">
          <div class="col-md-12 parent-temp">
            <h3>  TEMPERATURE  </h3>
                <div class="row temp_img">

                  <div class="col-md-1 col-md-offset-5">
                  <div id="temperature" class="disp_temp "></div>
                  <button class="btn btn-default">F</button>
                  </div>

                  <div class="col-md-1">
                    <img id="icon_img" class="" src="#" alt="weather_icon" >
                  </div>
                </div>
          </div>
        </div>
John
@AnonymousLords
Jul 09 2017 20:21 UTC
Eerything is under oen div...
You would have three seprate divs
Why did you include temptaure in the row?
aRtoo
@artoodeeto
Jul 09 2017 20:22 UTC
@John-freeCodeCamp thats the parent div
@John-freeCodeCamp see the the inner row?
John
@AnonymousLords
Jul 09 2017 20:23 UTC
Why is temperature inside of the row?
Its not even closed off
Ayush Mahajan
@ay2306
Jul 09 2017 20:23 UTC
Hey guys I am making simon game. and need some help.. How can I wait till user click color-button n times
my codepen: https://codepen.io/ayush2306/pen/PjyWpz?editors=1011
John
@AnonymousLords
Jul 09 2017 20:23 UTC
Look you dont close it off, so the button is under col-md-12 and col-md-1
aRtoo
@artoodeeto
Jul 09 2017 20:24 UTC
@John-freeCodeCamp nvm sir. thnk
John
@AnonymousLords
Jul 09 2017 20:25 UTC
@artoodeeto here is how its supposed to eb strtured when your using row
<div class="row">
  <div class="col-md-4">
    <h2> hello </h2>
  </div>
  <div class="col-md-4">
    <h2> hello </h2>
  </div>
  <div class="col-md-4">
    <h2> hello </h2>
  </div>
</div>
Everything in that row div equals to 12
Dovydas Stirpeika
@Giveback007
Jul 09 2017 20:26 UTC
so no solution then?
John
@AnonymousLords
Jul 09 2017 20:26 UTC
rooms
/rooms
CamperBot
@camperbot
Jul 09 2017 20:26 UTC

freeCodeCamp rooms:

:point_right: Here is a list of our official chat rooms

freeCodeCamp rooms:

:point_right: Here is a list of our official chat rooms
John
@AnonymousLords
Jul 09 2017 20:26 UTC
@Giveback007 Theirs a help fornt end room
front*
That might help more
@Giveback007 this room has a lot more people, so someone could help https://gitter.im/FreeCodeCamp/FreeCodeCamp
That undersatnds
Ayush Mahajan
@ay2306
Jul 09 2017 20:27 UTC
guys.. help me please
John
@AnonymousLords
Jul 09 2017 20:28 UTC
Im not sure about that, but ask this room https://gitter.im/FreeCodeCamp/FreeCodeCamp
James Patrick Kerrane
@jamesjpk123
Jul 09 2017 20:55 UTC

I need help:

var array;
function reverseString(str) {
  array = str.split("");
  array.reverse();
return array;
}

reverseString("hello");

Returns ["o","l","l","e","h"] I don't know how to turn this into a string. Can someone help me?

Kelechi Chinaka
@ke1echi
Jul 09 2017 20:58 UTC
use join @jamesjpk123
James Patrick Kerrane
@jamesjpk123
Jul 09 2017 21:00 UTC
Thanks @kelechy it worked!
CamperBot
@camperbot
Jul 09 2017 21:00 UTC
jamesjpk123 sends brownie points to @kelechy :sparkles: :thumbsup: :sparkles:
:warning: @kelechy's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
aRtoo
@artoodeeto
Jul 09 2017 21:00 UTC

help. how cna i adjust my button to get closer on the text. heres the codepen
https://codepen.io/artoo/pen/bRmrzz

heres the html. btw i cant use margin idont know why.

  <div class="parent-temp">
            <h3> TEMPERATURE</h3>
          </div>

      <div class="row temp-info">
          <div class="col-sm-1 col-sm-offset-5" id="temperature">

          </div>

          <div class="col-sm-1 ">
            <button class="btn btn-default">F</button>
          </div>

          <div class="col-sm-1 ">
            <img id="icon_img" class="" src="#" alt="weather_icon" >
          </div>
      </div>
James Patrick Kerrane
@jamesjpk123
Jul 09 2017 21:00 UTC
If you link your account and ping me @kelechy, i can give you cookies
@kelechy thanks again!
CamperBot
@camperbot
Jul 09 2017 21:01 UTC
jamesjpk123 sends brownie points to @kelechy :sparkles: :thumbsup: :sparkles:
:warning: @kelechy's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
moellennium
@moellennium
Jul 09 2017 21:14 UTC
I was wondering if I could get some help with my code camp challenge?
John
@AnonymousLords
Jul 09 2017 21:16 UTC
@artoodeeto Try using padding
@artoodeeto Just use "margin: -1%;" or "padding: -1%;"
@artoodeeto You could also use pixels instead of percents, but percents help on smaller screens.
aRtoo
@artoodeeto
Jul 09 2017 21:17 UTC
@John-freeCodeCamp aihgt ill try sir. thans
John
@AnonymousLords
Jul 09 2017 21:19 UTC
@artoodeeto type "thanks @person"
or "danke @person"
CamperBot
@camperbot
Jul 09 2017 21:19 UTC
john-freecodecamp sends brownie points to @person :sparkles: :thumbsup: :sparkles:
:warning: @person's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
moellennium
@moellennium
Jul 09 2017 21:20 UTC

function fearNotLetter(str) {
return string.fromCharCode();
}

fearNotLetter("abce");

I need help
John
@AnonymousLords
Jul 09 2017 21:20 UTC
@artoodeeto You may also have to do "margin-top: -1%;" and "margin-bottom"
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:21 UTC
@moellennium string.fromCharCode(); --> String.fromCharCode();
String.fromCharCode(65); // "A"
String.fromCharCode(66); // "B"
String.fromCharCode(65, 66, 67); // "ABC"
monkeyfingerz
@monkeyfingerz
Jul 09 2017 21:23 UTC
I'm getting an error code when i try to retrieve info from the wiki api. Is there something i have to enable to ajax the infromation?
$(document).ready(function(){
  //when search is clicked return code
  $('#search').click(function(){
   var searchTerm = $('searchTerm').val();
   var url = "https://en.wikipedia.org/w/api.php?action=opensearch&format=jsonfm&search="+searchTerm+"&namespace=0&limit=10";
  $.ajax({
    type:"GET",
    url:url,
    async:false,
    dataType:"json",
    success:function(data){
      console.log(data);
    },
    error:function(errorMessage){
      alrt("error");
    }
  });

  });

});
moellennium
@moellennium
Jul 09 2017 21:24 UTC
@saifsmailbox98 what do I do next?
monkeyfingerz
@monkeyfingerz
Jul 09 2017 21:25 UTC
What do i have to do in codepen to allow ajax requests from a third party api?
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:25 UTC
@moellennium code. grab the first letter check if the sequence is maintained or not and then return accordingly.
moellennium
@moellennium
Jul 09 2017 21:27 UTC
@saifsmailbox98 So How do I check to see if the sequence is maintained or not?
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:28 UTC
@moellennium you need to build the logic, try charCodeAt() to get the charCode of the letters.
monkeyfingerz
@monkeyfingerz
Jul 09 2017 21:29 UTC
Why can't i use the wiki api?
on codepen
moellennium
@moellennium
Jul 09 2017 21:31 UTC

@saifsmailbox98 should it look like this ?
function fearNotLetter(str) {
return string.CharCodeAt(65, 66, 67);

}

fearNotLetter("abce");

Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:32 UTC
@moellennium no, grab the charCode of the first letter and then keeping increment it and checking with the input.
AlliBun
@AlliBun
Jul 09 2017 21:32 UTC

how would I make it so that the temperature display changes based on the radio box selected?

if(document.getElementById('F').checked) {
  $('#temp').text(result.current.temp_f + '°F')
}
else if(document.getElementById('C').checked) {
  $('#temp').text(result.current.temp_c + '°C')
}

this is what I have, but it is not working

Manish Giri
@Manish-Giri
Jul 09 2017 21:32 UTC
@AlliBun probably should use the onchange event handler
inside that you can check what the value is with .checked
and display accordingly
Mikail Şeremet
@MikailSeremet
Jul 09 2017 21:33 UTC
@monkeyfingerz where do you live mate
monkeyfingerz
@monkeyfingerz
Jul 09 2017 21:33 UTC
washington @MikailSeremet
AlliBun
@AlliBun
Jul 09 2017 21:34 UTC
thank you @Manish-Giri
CamperBot
@camperbot
Jul 09 2017 21:34 UTC
allibun sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6219 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jul 09 2017 21:34 UTC
:+1:
moellennium
@moellennium
Jul 09 2017 21:37 UTC

@saifsmailbox98 So now it looks like this
function fearNotLetter(str) {
String.fromCharCode(65);
String.fromCharCode(66);
string.fromCharCode(67);
string.fromCharCode(68);
return string.CharCode(65, 66, 67, 68);

}

fearNotLetter("abce");

Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:38 UTC
@moellennium try looping it, you are not going to put every character like that.
Also you need to check if the next character is correct or not.
moellennium
@moellennium
Jul 09 2017 21:38 UTC
@saifsmailbox98 how do I do that?
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:39 UTC
@moellennium do you want a solution?
moellennium
@moellennium
Jul 09 2017 21:39 UTC
@saifsmailbox98 yes
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:41 UTC
@moellennium
  var  beg=str.charCodeAt(0);  //save the charcode of the first letter
  for(var i=0;i<str.length;i++){  // keep on iterating over the input string

    if(str.charCodeAt(i)!=beg+i){    //if the sequence breaks

      return String.fromCharCode(beg+i);  //return the missing letter
    }
aRtoo
@artoodeeto
Jul 09 2017 21:42 UTC
hi guys. how do you use herokuapp to run on codepen??
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:42 UTC
@artoodeeto on codepen?
moellennium
@moellennium
Jul 09 2017 21:43 UTC
@saifsmailbox98 thanks
CamperBot
@camperbot
Jul 09 2017 21:43 UTC
moellennium sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 742 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
aRtoo
@artoodeeto
Jul 09 2017 21:43 UTC
@saifsmailbox98 @saifsmailbox98 yeap sir. because on my weather app i used api that has HTTP not HTTPS. i didnt know that codepen doesnt accpet http
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:43 UTC
@artoodeeto try building locally, or use another api.
aRtoo
@artoodeeto
Jul 09 2017 21:44 UTC
@saifsmailbox98 im tired to re create a weather app again.
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:44 UTC
@artoodeeto share your pen please.
aRtoo
@artoodeeto
Jul 09 2017 21:45 UTC
@saifsmailbox98 k sir. wait
@saifsmailbox98 @saifsmailbox98 https://codepen.io/artoo/pen/bRmrzz
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:46 UTC
@artoodeeto try this https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?
aRtoo
@artoodeeto
Jul 09 2017 21:47 UTC
@saifsmailbox98 where should i put this??
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:47 UTC
@artoodeeto var api = 'https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?';
aRtoo
@artoodeeto
Jul 09 2017 21:48 UTC
@saifsmailbox98 doenst work sir
Luis
@zdrifted
Jul 09 2017 21:48 UTC
Nvm, solved it. element[index] in the if statement should just be element;
function getElementOfArrayProperty(obj, key, index) {
  // your code here
  var element = obj[key];
  console.log(element);
  console.log(element[index]);
  console.log(element.length);

  if(!Array.isArray(element[index]) || element.length === 0) {
    return undefined;
  } 

  return element[index];

}

getElementOfArrayProperty({ 1: [0, 1, 2]}, 1, 0);
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:49 UTC
@artoodeeto Allow location, it's loading the weather data for me
aRtoo
@artoodeeto
Jul 09 2017 21:50 UTC
@saifsmailbox98 allow where?
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:50 UTC
@artoodeeto try refrshing, then allow location on the top left
aRtoo
@artoodeeto
Jul 09 2017 21:51 UTC
@saifsmailbox98 codepen rigt?? doesnt work
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:51 UTC
image.png
Alexander Køpke
@alexanderkopke
Jul 09 2017 21:51 UTC
@monkeyfingerz in the url change to this: &format=json& and below change to this: dataType: "jsonp"
aRtoo
@artoodeeto
Jul 09 2017 21:52 UTC
@saifsmailbox98 ohh. thanks bro. ijust need to clearn the ocation
CamperBot
@camperbot
Jul 09 2017 21:52 UTC
artoodeeto sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 743 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Luis
@zdrifted
Jul 09 2017 21:53 UTC
Nvm, solved it
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 21:55 UTC
@artoodeeto :+1:
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 22:01 UTC
guys is there any way to insert tag between <someTag></someTag> in react dynamically....My Code Here arr = ["1","2","3","4",["1","2","3","4",[]]]
makeTags(arr) {
        for(var i=0; i<arr.length; i++){
            if(typeof arr[i] === "string"){
                var p = <PostPanel elem={arr} key={"panel "+arr}></PostPanel>;
                return p;
            }
            else if(typeof arr[i] === "object"){
                if(arr[i].length !== 0){
                    console.log(arr[i])
                }
            }
        }

    }
monkeyfingerz
@monkeyfingerz
Jul 09 2017 22:03 UTC
like this
$(document).ready(function(){
  //when search is clicked return code
  $('#search').click(function(){
   var searchTerm = $('searchTerm').val();
   var url = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json& &search="+searchTerm+"&namespace=0&limit=10";
  $.ajax({
    type:"GET",
    url:url,
    async:false,
    dataType:"jsonp",
    success:function(data){
      console.log(data);
    },
    error:function(errorMessage){
      alrt("error");
    }
  });

  });

});
@alexanderkopke
Alexander Køpke
@alexanderkopke
Jul 09 2017 22:05 UTC
@monkeyfingerz yeah but that shouldn't be a gap in your url & &.. just json&search=
monkeyfingerz
@monkeyfingerz
Jul 09 2017 22:07 UTC
@alexanderkopke thank you that was pretty frustrating
CamperBot
@camperbot
Jul 09 2017 22:07 UTC
monkeyfingerz sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1603 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Alexander Køpke
@alexanderkopke
Jul 09 2017 22:08 UTC
@monkeyfingerz searchTerm is that a class name? if yes then it needs a dot in front of it $(".searchTerm").val();
Moisés Man
@moigithub
Jul 09 2017 22:10 UTC
and... if an ID then need a # instead
moellennium
@moellennium
Jul 09 2017 22:10 UTC
@saifsmailbox98 beg means beginning right?
Luis
@zdrifted
Jul 09 2017 22:11 UTC
Any idea why this returns 4 instead of 3? Solved it with forEach but not exactly sure why this approach failed
function getLengthOfShortestElement(arr) {
  // your code here
  if (arr.length === 0) {
    return 0;
  }

  var shortest = arr[0].length;

  return arr.reduce(function(str) {
    if (str.length < shortest) {
      return shortest = str.length;
    } else {
      return shortest;
    }
  }, shortest);
}

getLengthOfShortestElement(['luis', 'cod', 'length']);
Stephen James
@sjames1958gm
Jul 09 2017 22:25 UTC
@Rushh @Rushh because the first parameter to the reduce function is the accumulated value not the next value
Luis
@zdrifted
Jul 09 2017 22:29 UTC
What do you mean?
Oh so it should be function(shortest, value)...
or (shortest, str)
Stephen James
@sjames1958gm
Jul 09 2017 22:30 UTC
@Rushh yes.
John
@AnonymousLords
Jul 09 2017 22:30 UTC
Guys did i do this challange correctly? I still dont understand what their talking about. All i did was add var myGlobal = 10; oopsGlobal = 5; I didn't assign 5 oopsGlobal :worried: . Heres my code
Luis
@zdrifted
Jul 09 2017 22:30 UTC
Thanks! @sjames1958gm
CamperBot
@camperbot
Jul 09 2017 22:30 UTC
rushh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8027 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John
@AnonymousLords
Jul 09 2017 22:31 UTC

// Declare your variable here

var myGlobal = 10;
oopsGlobal = 5;

function fun1() {
  // Assign 5 to oopsGlobal Here

}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
Stephen James
@sjames1958gm
Jul 09 2017 22:31 UTC
@John-freeCodeCamp look at the comment it says where to assign 5 to oopsGlobal
John
@AnonymousLords
Jul 09 2017 22:32 UTC
I didnt even assign the 5 oopsglobal's and i still passed teh challange. I kinda cheated i dont understand what they mean by assigning it
Stephen James
@sjames1958gm
Jul 09 2017 22:32 UTC
oopsGlobal = 5; this line is supposed to be inside fun1() {}
John
@AnonymousLords
Jul 09 2017 22:32 UTC
Am i doing a math equation? Like oopsGlobal += myGlobal +- oopsGlobal
Ohhh
So is this correct

// Declare your variable here

var myGlobal = 10;


function fun1() {
  // Assign 5 to oopsGlobal Here
  oopsGlobal = 5;
}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
Stephen James
@sjames1958gm
Jul 09 2017 22:33 UTC
THe idea is that you forgot the var keyword so oopsGlobal is accidentally a global vairbale
@John-freeCodeCamp yes
John
@AnonymousLords
Jul 09 2017 22:34 UTC
It still worked teh other way around?
Stephen James
@sjames1958gm
Jul 09 2017 22:34 UTC
@John-freeCodeCamp seems the tests are not sufficient in detecting that case
John
@AnonymousLords
Jul 09 2017 22:35 UTC
SHould i report it as a bug?
@sjames1958gm ello?
@sjames1958gm Anyways thanks
CamperBot
@camperbot
Jul 09 2017 22:38 UTC
john-freecodecamp sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8028 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 22:41 UTC
@moellennium yes
John
@AnonymousLords
Jul 09 2017 22:41 UTC
/bug
Nota command :O
CallMeOrange
@EgnaroDev
Jul 09 2017 22:48 UTC
@saifsmailbox98 hey, can you explain how this work?
$.getJSON(
      "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=json"+Math.random(),
      function(json)
Why Math.random() change the quote of API
Thomas
@sjurs1
Jul 09 2017 22:52 UTC

Hi guys. Working with the wikipedia API to grab the first ten search results as well as an extract from each resulting article. This is the URL I'm using for my ajax request:
"https://en.wikipedia.org/w/api.php?format=json&origin=*&action=query&generator=search&prop=extracts&exlimit=10&exintro=true&gsrsearch="

The resulting json contains everything I want, but in order to access the extract and title properties, I have to get past object properties that have the article's wikipedia page ids as their names. For example:

Object {736: Object, 319759: Object, 1755232: Object, 3720557: Object, 3887135: Object, 12333667: Object, 12738235: Object, 18742711: Object, 24004485: Object, 27238977: Object}

Do I have to loop through the object and use hasOwnProperty and assign to a variable or is there a better way? If you guys have experience with the wikipedia API, I'd welcome any suggestions regarding my URL. I'd use list=search, but I can't combine list and prop, which is why I'm using generator=search.

Janice He
@Janicekwing
Jul 09 2017 22:54 UTC
hello, can someone help me with the challenge of capitalizing the first character of each element in an array? I know the issue and don't know how to get around it
Chase
@Belax8
Jul 09 2017 22:55 UTC
@MCTwoDigitZero My only guess would be that your browser is caching the response so, when you add the math.random(), it thinks it's a new request and doesn't look at your cached response.
CallMeOrange
@EgnaroDev
Jul 09 2017 22:56 UTC
@Belax8 thanks, I asked this question for someone else
CamperBot
@camperbot
Jul 09 2017 22:56 UTC
mctwodigitzero sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
:cookie: 449 | @belax8 |http://www.freecodecamp.com/belax8
Moisés Man
@moigithub
Jul 09 2017 23:00 UTC
query.pages will return a big objects with keys like 736, 319759.. which contains objects as its values
u can use Object.keys on query.pages to get a list/array with those keys/numbers
having the object (query.pages) and the key u can access whatever info u need
@sjurs1
Thomas
@sjurs1
Jul 09 2017 23:01 UTC
@moigithub Totally forgot about Object.keys!!! Thanks a lot :)
CamperBot
@camperbot
Jul 09 2017 23:01 UTC
sjurs1 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3488 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jul 09 2017 23:07 UTC
@MCTwoDigitZero jquery allows u setup a cache property
$.ajaxSetup({cache:false})
which internally will do something similar when it execute the request (it use a timestamp instead, its on the documentation)
Veronica Eulenberg
@HappyViki
Jul 09 2017 23:09 UTC
HELP MEEEEEEE I want this over with. Primes are driving me insane! Why is this returning 46 instead of 17?
function sumPrimes(num) {
  var nums = [];
  var prime = 2;
  for (var p = 2; p <= 10; p++) {
    console.log("yo");
    var lol = nums.reduce(function(a,b){
      console.log(p, b, p%b !== 0);
      if (p%b !== 0) return b;

    }, 0);
    prime += lol;
    nums.push(p);
  }
  console.log(lol);
  return prime;
}

// 2 3 4 5 6 7 8 9 10
console.log(sumPrimes(10));
Chase
@Belax8
Jul 09 2017 23:12 UTC
@HappyViki I just sent you a PM
Stephen James
@sjames1958gm
Jul 09 2017 23:14 UTC
@Janicekwing What is the issue?
Janice He
@Janicekwing
Jul 09 2017 23:15 UTC
@sjames1958gm this is my code right now
function titleCase(str) {
  str = str.toLowerCase();
  var arr = str.split(' ');
  for (i = 0; i < arr.length; i++){
       arr[i].charAt(0) = arr[i].charAt(0).toUpperCase();
  }
  arr = arr.join(" ");
  return arr;
}
The issue is the statement in my for-loop
Stephen James
@sjames1958gm
Jul 09 2017 23:16 UTC
@Janicekwing YOu cannot change a single character in a string. You need to set arr[i] to the changed first letter + the rest of the word
Janice He
@Janicekwing
Jul 09 2017 23:17 UTC
I see
one sec
Moisés Man
@moigithub
Jul 09 2017 23:17 UTC
var str = "Jello World"
str[0]="H"//<< Error.. if u recall that exercise
string immutability
Janice He
@Janicekwing
Jul 09 2017 23:18 UTC
@sjames1958gm I'm not really sure how to get the "rest of the word"...
Stephen James
@sjames1958gm
Jul 09 2017 23:18 UTC
@Janicekwing slice, or substr
Janice He
@Janicekwing
Jul 09 2017 23:20 UTC
@sjames1958gm but would it look like this arr[i].slice(1, -1) arr[i].substring(1, -1)
I'm not sure how to get to the end?
nvm I figured it out
arr[i].length :)
Stephen James
@sjames1958gm
Jul 09 2017 23:21 UTC
str.slice(1) will go from the second character to the end.
Janice He
@Janicekwing
Jul 09 2017 23:21 UTC
@sjames1958gm thank youu :*
CamperBot
@camperbot
Jul 09 2017 23:21 UTC
janicekwing sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8029 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 09 2017 23:21 UTC
@Janicekwing :+1:
Veronica Eulenberg
@HappyViki
Jul 09 2017 23:24 UTC
@Belax8 Thanks :)
function sumPrimes(num) {
  var result = 0;

  for(var i = 2; i <= num; i++) {
    for(var j = 2; j <= i; j++){

      if (i === j) {
        result += i;
      }

      if (i % j === 0) {
        break;
      }
    }
  }


  return result;
}
CamperBot
@camperbot
Jul 09 2017 23:24 UTC
happyviki sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
:cookie: 450 | @belax8 |http://www.freecodecamp.com/belax8
Veronica Eulenberg
@HappyViki
Jul 09 2017 23:25 UTC
@Belax8 Even more compact :P
function sumPrimes(num) {
  var result = 0;

  for(var i = 2; i <= num; i++) {
    for(var j = 2; j <= i; j++){

      if (i === j) result += i; 
      if (i % j === 0) break;
    }
  }
  return result;
}
AlliBun
@AlliBun
Jul 09 2017 23:26 UTC
https://codepen.io/Erynfi/pen/PjdxKW
my button changing function isn't working
$('#change').on('click',function(){
        if (mes=1){ // if mes is f
$('#temp').text(result.current.temp_c +  '°C');
            mes = 0;  // sets mes to c
        }
        if (mes=0){ // if mes is c
    $('#temp').text(result.current.temp_f + '°F'); 
            mes = 1; // sets mes to f
        }
Manish Giri
@Manish-Giri
Jul 09 2017 23:27 UTC
@AlliBun == or ===
to compare
= is just assignment
AlliBun
@AlliBun
Jul 09 2017 23:27 UTC
whoops, thank you
John
@AnonymousLords
Jul 09 2017 23:27 UTC
Why doesnt this code work on challenge https://www.freecodecamp.org/challenges/local-scope-and-functions ?

function myLocalScope() {
  'use strict';
  var myVar = "foo";

  console.log(myVar);
}
myLocalScope(myVar);
var myVar = "foo";
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test
Tom Gause
@Tom-Gause
Jul 09 2017 23:28 UTC
Hey guys. On the lesson that teaches switch statements, I wrote the code, and I passed the test, but I feel like my code is clunky and unnecessarily long. Would someone mind taking a look at it and help me see what I'm missing?
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1: answer=("alpha");
      break;
    case 2: answer=("beta");
      break;
    case 3: answer=("gamma");
      break;
    case 4: answer=("delta");

  }
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
John
@AnonymousLords
Jul 09 2017 23:30 UTC
Tom Gause
@Tom-Gause
Jul 09 2017 23:30 UTC
@John-freeCodeCamp Once you have everything typed up, delete the last line, the console.log(myVar);
John
@AnonymousLords
Jul 09 2017 23:31 UTC
?what is everything "Typed up"

function myLocalScope() {
  'use strict';
  var myVar = "foo";

  console.log(myVar);
}
myLocalScope(myVar);
This is my new code
Ravi Kishore Thella
@ravikishorethella
Jul 09 2017 23:32 UTC
@Tom-Gause your code is working to me
Tom Gause
@Tom-Gause
Jul 09 2017 23:32 UTC
My code works, I just feel like I'm missing something, I feel like there is an easier way to write it, that I'm missing
Ravi Kishore Thella
@ravikishorethella
Jul 09 2017 23:33 UTC
@Tom-Gause no you are not
@Tom-Gause as per the instructions, that the best way to do
John
@AnonymousLords
Jul 09 2017 23:34 UTC
@Tom-Gause Is my new code right
Tom Gause
@Tom-Gause
Jul 09 2017 23:34 UTC
@ravikishorethella I see. Thanks a lot!
CamperBot
@camperbot
Jul 09 2017 23:34 UTC
tom-gause sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 930 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
Ravi Kishore Thella
@ravikishorethella
Jul 09 2017 23:34 UTC
@Tom-Gause :thumbsup:
Tom Gause
@Tom-Gause
Jul 09 2017 23:34 UTC
@John. You're almost there
John
@AnonymousLords
Jul 09 2017 23:34 UTC
@Tom-Gause It has a X on "No global myVar variable"
Ravi Kishore Thella
@ravikishorethella
Jul 09 2017 23:35 UTC
@John-freeCodeCamp a variable is said to be global if it is declared outside of the function. global var should be declared outside of the function
John
@AnonymousLords
Jul 09 2017 23:35 UTC
Okay ill try
Tom Gause
@Tom-Gause
Jul 09 2017 23:35 UTC
Underneath the myLocalScope(myVar); type var myVar = "foo";
John
@AnonymousLords
Jul 09 2017 23:36 UTC

function myLocalScope() {
  'use strict';
 var myVar = "foo";

  console.log(myVar);
}
myLocalScope(myVar);
var myVar = "foo";
This is my new code, still saying their is No global myVar variable
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 23:37 UTC
guys is there any way to send Data from child component to parent Component in React?
Tom Gause
@Tom-Gause
Jul 09 2017 23:37 UTC
@John-freeCodeCamp What is the title of your lesson?
Ravi Kishore Thella
@ravikishorethella
Jul 09 2017 23:38 UTC
@John-freeCodeCamp :point_up: July 9, 2017 7:35 PM
Stephen James
@sjames1958gm
Jul 09 2017 23:38 UTC
@Saikat-Sinha If you pass a function as a callback you can have the child component call that function to set a value in the parent
Tom Gause
@Tom-Gause
Jul 09 2017 23:39 UTC
@John. reset your code.
Ravi Kishore Thella
@ravikishorethella
Jul 09 2017 23:39 UTC
@John-freeCodeCamp var myVar should be declared outside the function i.e even before starting the function
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 23:39 UTC
@sjames1958gm thanks bro
CamperBot
@camperbot
Jul 09 2017 23:39 UTC
saikat-sinha sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8030 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 09 2017 23:39 UTC
@Saikat-Sinha :+1:
Tom Gause
@Tom-Gause
Jul 09 2017 23:40 UTC
@John-freeCodeCamp All you need to do is declarer a variable, like you have. Then remove the console.log line
John
@AnonymousLords
Jul 09 2017 23:40 UTC
okay i removed console.log and this is teh code


function myLocalScope() {
  'use strict';

}
var myVar = "foo";
myLocalScope(myVar);
I removed one prevosuily, but someone told me to remove it again...
Tom Gause
@Tom-Gause
Jul 09 2017 23:41 UTC
your var myVar should be inside the function
put it above the }, under the 'use strict'
John
@AnonymousLords
Jul 09 2017 23:42 UTC
It already is
"console.log never called"
Tom Gause
@Tom-Gause
Jul 09 2017 23:43 UTC
You need to have var myVar = "foo"; and console.log(myVar); above the curly bracket.
pahosler
@pahosler
Jul 09 2017 23:44 UTC
does anyone know why a script would run in codepen ok but not so well on personal web space? All css and libraries, etc.. have been ported over to the host provider, and issues are the same on home webserver as the hosting provider...
John
@AnonymousLords
Jul 09 2017 23:44 UTC


function myLocalScope() {
  'use strict';
  var myVar = "foo";
  console.log(myVar);
}
myLocalScope(myVar);
pahosler
@pahosler
Jul 09 2017 23:45 UTC
timers and events are wonky...
John
@AnonymousLords
Jul 09 2017 23:45 UTC
No global myVar varaible
Joseph
@revisualize
Jul 09 2017 23:46 UTC
@John-freeCodeCamp Is that ALL of the code?
Tom Gause
@Tom-Gause
Jul 09 2017 23:46 UTC
now where it says myLocalScope(myVar);, take out the myVar and leave the parenthesis empty
John
@AnonymousLords
Jul 09 2017 23:47 UTC
now is all the code
function myLocalScope() {
  'use strict';
  var myVar = "foo";
  console.log(myVar);
}
myLocalScope();
Tom Gause
@Tom-Gause
Jul 09 2017 23:47 UTC
Yes
That should work
John
@AnonymousLords
Jul 09 2017 23:47 UTC
X No global myVar variable
Tom Gause
@Tom-Gause
Jul 09 2017 23:48 UTC
Show me your whole cose?
code?
John
@AnonymousLords
Jul 09 2017 23:48 UTC
Thats all of it
Its teh challange
is it glicthed?
Tom Gause
@Tom-Gause
Jul 09 2017 23:49 UTC
I run the code you have, and it works for me. Have you accidentally commented something out?
John
@AnonymousLords
Jul 09 2017 23:50 UTC
It looks exaclty like that, how do i get a screenshot of my screen?
It looks exactly like that, but 'use strict' is yellow.
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 23:52 UTC
@MCTwoDigitZero it's not the Math.random(), even you remove it it'll work.
@MCTwoDigitZero try visiting https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=json multiple times.
@John-freeCodeCamp try refreshing
John
@AnonymousLords
Jul 09 2017 23:55 UTC
@saifsmailbox98 that worked
thanks @Tom-Gause @saifsmailbox98
CamperBot
@camperbot
Jul 09 2017 23:55 UTC
john-freecodecamp sends brownie points to @tom-gause and @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @tom-gause |http://www.freecodecamp.com/tom-gause
:cookie: 744 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
John
@AnonymousLords
Jul 09 2017 23:55 UTC
Refreshing worked @Tom-Gause
Tom Gause
@Tom-Gause
Jul 09 2017 23:55 UTC
Great!