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

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
The last 2 properties haven't values
but why are you using brackets there?
korzo
@korzo
Jul 09 2017 00:15
@Arontbt It will always return word !== false (true) . And if word is false, it returns NaN
Diego Mayer
@Chrono79
Jul 09 2017 00:15
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
$.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 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 @Hijerboa is this because of forcast? forecast? Moisés Man @moigithub Jul 09 2017 01:02 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 @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 @Hijerboa Ah I see aRtoo @artoodeeto Jul 09 2017 01:09 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(){
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);
}
})
}

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
@artoodeeto You posted the same thing on 3 chats :P
aRtoo
@artoodeeto
Jul 09 2017 01:11
@John-freeCodeCamp yes bro. because someone might help me on other rooms
help bro
John
@AnonymousLords
Jul 09 2017 01:12
@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
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
@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

@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
backticks on its OWN line @moyamanuel
Manuel Moya
@moyamanuel
Jul 09 2017 01:40
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
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
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
@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
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
Ah, I see! Thanks guys @fmccroy @moigithub !
CamperBot
@camperbot
Jul 09 2017 01:47
moyamanuel sends brownie points to @fmccroy and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3482 | @moigithub |http://www.freecodecamp.com/moigithub
aRtoo
@artoodeeto
Jul 09 2017 02:17
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
@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
@MCTwoDigitZero omg. someone bite me!!
CallMeOrange
@EgnaroDev
Jul 09 2017 02:27
@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
@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?
CallMeOrange
@EgnaroDev
Jul 09 2017 02:29
I have two APIs for https
Darksky api or apixu.com
aRtoo
@artoodeeto
Jul 09 2017 02:31
@MCTwoDigitZero thanks. omg!! im tired!
CamperBot
@camperbot
Jul 09 2017 02:31
artoodeeto sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
CallMeOrange
@EgnaroDev
Jul 09 2017 02:31
No problem
Frank McCroy
@fmccroy
Jul 09 2017 02:31
Someone made a weather API just for FCC, you can see it here: freeCodeCamp/freeCodeCamp#15598
aRtoo
@artoodeeto
Jul 09 2017 02:32
@MCTwoDigitZero btw. can i host my weather app and pass the link??
Mai Thinh
@mthinh
Jul 09 2017 02:32



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
@fmccroy Do you think it is ok to use a key in codepen?
Frank McCroy
@fmccroy
Jul 09 2017 02:37
@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
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
@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
I see
Moisés Man
@moigithub
Jul 09 2017 02:43
u only push AFTER check ALL sources keys/values, not only first match @mthinh
Mai Thinh
@mthinh
Jul 09 2017 02:44
yeah i realized that mistake , but dont know how to fix
Moisés Man
@moigithub
Jul 09 2017 02:46
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
$(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],
'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;

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
another way is using .every method @mthinh
Mai Thinh
@mthinh
Jul 09 2017 02:47
@moigithub ok tks
@moigithub thank you
CamperBot
@camperbot
Jul 09 2017 02:47
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
console.log(twitchArray[i]);
this line
Moisés Man
@moigithub
Jul 09 2017 02:49
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
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
soo doing twitchArray[ twitchArray.length ] dont exist.. returning undefined
CallMeOrange
@EgnaroDev
Jul 09 2017 02:52
last index is always blah.length - 1
I think :wink:
Moisés Man
@moigithub
Jul 09 2017 02:53
to solve u need to keep i value .. u can do that using functions or using block scope
Jul 09 2017 02:53
@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
CamperBot
@camperbot
Jul 09 2017 02:54
joetinnyspace sends brownie points to @moigithub and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3484 | @moigithub |http://www.freecodecamp.com/moigithub
AlliBun
@AlliBun
Jul 09 2017 02:59
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

//初始化变量
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
@AlliBun Not the answer, but I did that project using switch case( if that helps)
AlliBun
@AlliBun
Jul 09 2017 03:01
oh, I forgot that switch case exists, thank you @JoeTinnySpace
CamperBot
@camperbot
Jul 09 2017 03:01
allibun sends brownie points to @joetinnyspace :sparkles: :thumbsup: :sparkles:
2895388807
@2895388807
Jul 09 2017 03:02
Frank McCroy
@fmccroy
Jul 09 2017 03:03
@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.
Jul 09 2017 03:05

@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
@fmccroy so how to fix it? i still dont know how to place this return
Jul 09 2017 03:06
@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
Frank McCroy
@fmccroy
Jul 09 2017 03:07
@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.
Jul 09 2017 03:07
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
ok thx guys i try it
Jul 09 2017 03:09
@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
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
@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
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
@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
@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
My plan is to iterate through the array for characters to add 13 if they are letters
2895388807
@2895388807
Jul 09 2017 03:23
thx man
connor-5
@connor-5
Jul 09 2017 03:23
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
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
Yeah it was a pain for me when I did it haha
Frank McCroy
@fmccroy
Jul 09 2017 03:25
@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
Lol, thank y'all for your help!
@sandsbe
Jul 09 2017 03:29
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
;<-- statement terminator @sandsbe
@sandsbe
Jul 09 2017 03:43
Very nice find. I can work with this. Thanks @moigithub
CamperBot
@camperbot
Jul 09 2017 03:43
sandsbe sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3485 | @moigithub |http://www.freecodecamp.com/moigithub
CallMeOrange
@EgnaroDev
Jul 09 2017 04:30
background stay when scrolling but how do I make box also stay like background-attachment: fixed;?
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:35
@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
@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
@MCTwoDigitZero why do you want to use 2 position style attributes ? on an element
CallMeOrange
@EgnaroDev
Jul 09 2017 04:48
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
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;
return n + (Array(len - i-1).fill(0)).join("");
});
var match =
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){
response.push(inputs[key]);
}}};
return response;
}
convertToRoman(36);
CallMeOrange
@EgnaroDev
Jul 09 2017 04:49
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
@MCTwoDigitZero try it out
CallMeOrange
@EgnaroDev
Jul 09 2017 04:50
@Lumexralph What else can I make background bigger?
margin-bottom is only thing I know :/
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:54
@MCTwoDigitZero you background-size ?
CallMeOrange
@EgnaroDev
Jul 09 2017 04:54
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
@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
@Lumexralph should response be a global variable?
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:58
@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
perfect, I used auto, 100% instead
@Lumexralph thanks
CamperBot
@camperbot
Jul 09 2017 04:58
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
@MCTwoDigitZero CSS is another beast!!!
CallMeOrange
@EgnaroDev
Jul 09 2017 04:59
:)
Ogundele Olumide
@Lumexralph
Jul 09 2017 04:59
@surferpilgrim for the later part of the code to generate the roman numerals, you can still use map
@sandsbe
Jul 09 2017 05:15
Anyone finish the No Repeats Please challenge?
Long Nguyen
@longnt80
Jul 09 2017 05:17
@sandsbe yes
@sandsbe
Jul 09 2017 05:19
@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
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
@sandsbe
Jul 09 2017 05:25
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
sandsbe sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
Long Nguyen
@longnt80
Jul 09 2017 05:31
@sandsbe np
Sanket Chaudhari
@sanket143
Jul 09 2017 05:37
Mai Thinh
@mthinh
Jul 09 2017 05:38
@sanket143 nice
Sanket Chaudhari
@sanket143
Jul 09 2017 05:39
thanks but have some problem @mthinh
CamperBot
@camperbot
Jul 09 2017 05:39
sanket143 sends brownie points to @mthinh :sparkles: :thumbsup: :sparkles:
Sanket Chaudhari
@sanket143
Jul 09 2017 05:39
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
@sanket143 im sr, i dont know
Sanket Chaudhari
@sanket143
Jul 09 2017 05:45
@mthinh How could I fix it
aRtoo
@artoodeeto
Jul 09 2017 06:13
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
@Rushh
Jul 09 2017 06:27
Any idea why this algorithm isn't returning the index? I'm not allowed to use str.indexOf()
function getIndexOf(char, str) {
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
morning folks
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:31
@Rushh forEach method of an array returns undefined
Luis
@Rushh
Jul 09 2017 06:31
Why is index undefined?
aRtoo
@artoodeeto
Jul 09 2017 06:31
@Rushh reading it right now cant understand shit.
Luis
@Rushh
Jul 09 2017 06:32
It does look confusing. Try this? https://www.youtube.com/watch?v=PjVed86oPKk
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:32
@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
@Rushh
Jul 09 2017 06:34
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
@Rushh it's the way forEach was constructed
Luis
@Rushh
Jul 09 2017 06:38
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) {
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
@Rushh how about removing the else if statement
why do you need it?
Luis
@Rushh
Jul 09 2017 06:43
I need to return -1 if char is not found in the string
Ogundele Olumide
@Lumexralph
Jul 09 2017 06:46
@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) {
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
@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
@Rushh
Jul 09 2017 06:53
Oh I see
function getIndexOf(char, str) {
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
@Rushh
Jul 09 2017 06:59
Nvm I see what you mean about saving the first index found
aRtoo
@artoodeeto
Jul 09 2017 07:09
why im getting 0??
var date = new Date(1499655885);
var hours = date.getHours();
console.log(hours);
Luis
@Rushh
Jul 09 2017 07:09
Took a break and got it! Thanks @Lumexralph
CamperBot
@camperbot
Jul 09 2017 07:09
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
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
What's keeping you from using a forEach?
Mai Thinh
@mthinh
Jul 09 2017 07:21
I tried to use forEach but it doesnt work
Long Nguyen
@longnt80
Jul 09 2017 07:22
@mthinh show your code using forEach
Mai Thinh
@mthinh
Jul 09 2017 07:23
strArr.forEach(function(val){})
Opp sr im not on pc now
Long Nguyen
@longnt80
Jul 09 2017 07:26
Mai Thinh
@mthinh
Jul 09 2017 07:27
Oh i didnt pass i parameter , why is that ?
Luis
@Rushh
Jul 09 2017 07:27
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
@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
You don't have to provide a function with three parameters.
Long Nguyen
@longnt80
Jul 09 2017 07:30
@Pethaf of course, but he should know all three
Luis
@Rushh
Jul 09 2017 07:30
@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
Thank you Long Nguyen
Long Nguyen
@longnt80
Jul 09 2017 07:34
@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
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
@mthinh no
not without real projects experience where you have to work with other team members
Luis
@Rushh
Jul 09 2017 07:37
@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
@Rushh yeah, different people need different methods
Mai Thinh
@mthinh
Jul 09 2017 07:38
@longnt80 im self-studying. Do you have any advice ? Can self-taught people get a job?
Long Nguyen
@longnt80
Jul 09 2017 07:38
@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
@Rushh
Jul 09 2017 07:41
True
Long Nguyen
@longnt80
Jul 09 2017 07:41
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
@Rushh
Jul 09 2017 07:43
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
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
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
@hashtagyolo1 is that 1 on 1 tutoring?
Luis
@Rushh
Jul 09 2017 07:56
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
@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
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
@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
@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
@Manish-Giri legendary sssggggggggggggggm :smiling_imp:
Manish Giri
@Manish-Giri
Jul 09 2017 08:17
lol :joy:
that's @joreyesl
manuchehr94
@manuchehr94
Jul 09 2017 08:17
@Manish-Giri @Lumexralph thanks
CamperBot
@camperbot
Jul 09 2017 08:17
: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
@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
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
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
high five :wave:
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:21
@Manish-Giri but that's why you're legendary
Manish Giri
@Manish-Giri
Jul 09 2017 08:22
lol
i iz a n00b
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 08:22
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
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
@Lumexralph me in a few weeks
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:23
@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
Any React Devs?
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:24
@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
@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
@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
don't mind me
i've to go bro! be good
Manish Giri
@Manish-Giri
Jul 09 2017 08:28
lol
pls
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:29
okay he's a NOOB
Manish Giri
@Manish-Giri
Jul 09 2017 08:29
:+1:
Ogundele Olumide
@Lumexralph
Jul 09 2017 08:30
whatever ! :smirk: :wave:
Manish Giri
@Manish-Giri
Jul 09 2017 08:31
:wave:
Gokula Krishna
@AKX-X-32
Jul 09 2017 08:41
hey guys
makalohri
@makalohri
Jul 09 2017 09:56
@knrt10 thank you man
CamperBot
@camperbot
Jul 09 2017 09:56
makalohri sends brownie points to @knrt10 :sparkles: :thumbsup: :sparkles:
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:08
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
@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
@sjames1958gm thank you
CamperBot
@camperbot
Jul 09 2017 11:12
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
@JoeTinnySpace :+1:
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:14
How long have you been learning?
Jul 09 2017 11:14
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
@JoeTinnySpace I have been working in javascript for a couple of years. Programming in general longer.
Joseph Joe
@JoeTinnySpace
Jul 09 2017 11:16
@sjames1958gm Aye Wise Captain
Jul 09 2017 11:17
lol
@sjames1958gm any idea ?
Stephen James
@sjames1958gm
Jul 09 2017 11:19
Jul 09 2017 11:21
@sjames1958gm OAuth ?
Stephen James
@sjames1958gm
Jul 09 2017 11:23
I guess if you are authorized by the RSS source it should attach the cross site headers. I am only speculating
Jul 09 2017 11:26
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
Have you tried a library like rss-parser?
Jul 09 2017 11:32
I'll check it out, thx
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 11:32

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>
Jul 09 2017 11:33
It's not clear what are you trying to achieve
Saikat-Sinha
@Saikat-Sinha
Jul 09 2017 11:34
check the comment property
WAINGOR
@WAINGOR
Jul 09 2017 11:47
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

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

if (dropDownMenu.classList != "open") {
} else {
}

});

Emmanx
@Emmanx
Jul 09 2017 11:55
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
@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 @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 @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 @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 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 @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 remove true ramarcinek @ramarcinek Jul 09 2017 12:12 Yeah :) it works! Thank you very much! Alan Alickovic @alan2207 Jul 09 2017 12:13 you are welcome :smile: Joseph Joe @JoeTinnySpace Jul 09 2017 12:24 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 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 Hi Im stuck in the challenge where you have to return every first character of words of a string capitalised here is my code Stephen James @sjames1958gm Jul 09 2017 12:35 @Saikat-Sinha Why not have PostPanel decide whether to include the data from ele[4]? John @AnonymousLords Jul 09 2017 12:35 @fmccroy i fixed that, and it still wrong :worried: thx anyways CamperBot @camperbot Jul 09 2017 12:35 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 @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 . Arnish @arnishg Jul 09 2017 12:36 Ohh, Got it @sjames1958gm thanks CamperBot @camperbot Jul 09 2017 12:36 arnishg sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 8024 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm John @AnonymousLords Jul 09 2017 12:36 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 @John-freeCodeCamp Are you supposed to remove the first or last entry? pop removes the last John @AnonymousLords Jul 09 2017 12:38 OH Stephen James @sjames1958gm Jul 09 2017 12:38 @John-freeCodeCamp You changed the line that said myArray.shift() Moisés Man @moigithub Jul 09 2017 12:38 pop dont use any values. just arr.pop() @John-freeCodeCamp John @AnonymousLords Jul 09 2017 12:39 Thanks @fmccroy @sjames1958gm @moigithub CamperBot @camperbot Jul 09 2017 12:39 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 @JoeTinnySpace Twitch always seems to give me fits when linking to it @John-freeCodeCamp :+1: judgejab @judgejab Jul 09 2017 13:00 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 @judgejab try adding ^ and $ to the regex.
judgejab
@judgejab
Jul 09 2017 13:04
Thank you! I tried the $but didn't think of the ^ too, thanks @saifsmailbox98 CamperBot @camperbot Jul 09 2017 13:04 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 @judgejab you need to add both as "42 42 42 42" will match if you only have $.
judgejab
@judgejab
Jul 09 2017 13:05
got it :)
Saif Ur Rahman
@saifsmailbox98
Jul 09 2017 13:06
@judgejab :+1:
Jul 09 2017 13:10
@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
@khaduch thanks, i have wanted to learn regex for so long
CamperBot
@camperbot
Jul 09 2017 13:12
teevik sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jul 09 2017 13:13
@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
hey any of you guys have some tips for the Chunky Monkey challenge?
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:18
@Sofeo .slice and Math
otherwise: while loop with 1 edge case in mind: a chunk of size 0
Jul 09 2017 13:20
@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
slice manually.. find the correct indices.. then refactor with a loop @Sofeo
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:25
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 $\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
@luishendrix92 can you exsplain that a little more simple?
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:36
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
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
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
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
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
ok thanks for the help
@luishendrix92
Luis Felipe López G.
@luishendrix92
Jul 09 2017 13:40
.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
Hi again! I continue no understanding why reverse geo locate dosent return the name of my city.
$.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
@luccifer00 &? seems wrong
luccifer00
@luccifer00
Jul 09 2017 14:12
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
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
@mthinh nothing equals NaN even NaN
if value !== value then value is NaN
luccifer00
@luccifer00
Jul 09 2017 14:15
@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
so how to use isNaN ?
Stephen James
@sjames1958gm
Jul 09 2017 14:17
@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
@sjames1958gm thank you
CamperBot
@camperbot
Jul 09 2017 14:25
mthinh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8026 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kamal
@kpbro
Jul 09 2017 14:37
{"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
@kpbro What values do you intend to extract out of it?
Kamal
@kpbro
Jul 09 2017 14:37
like if it is a then a.weather or a.main?
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:38
right
Kamal
@kpbro
Jul 09 2017 14:38
all contents from main and wind
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:39
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
oh.. i see and if i use only a.main what it will return?
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:39
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
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
@kpbro do you have codepen for this?
Kamal
@kpbro
Jul 09 2017 14:44
yeah
Stephen James
@sjames1958gm
Jul 09 2017 14:46
@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
oh mann.. i didnt know that
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:48
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
why &callback= is needed?
&callback=?
Fox Martin
@fmartin5
Jul 09 2017 14:50
to tell jQuery it's a request for JSONP data
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:50
@kpbro to make cross domain ajax request
JSONP
Kamal
@kpbro
Jul 09 2017 14:51
fcc didnt teach any of these :worried:
Sweet Coding :)
@SweetCodingInc
Jul 09 2017 14:58
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
@SweetCodingInc yes.
Kamal
@kpbro
Jul 09 2017 15:11
@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
this should show time zone of location instead of 'weather here' text
Moisés Man
@moigithub
Jul 09 2017 15:19
@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

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
Kamal
@kpbro
Jul 09 2017 15:25
yea. i read it. what should i do?
Moisés Man
@moigithub
Jul 09 2017 15:26
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
@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
cuz async ?? (explained above)
Kamal
@kpbro
Jul 09 2017 15:31
yes..
iam clear now
shashankspecter99
@shashank1999coder
Jul 09 2017 15:38

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

function myObj(checkProp) {
}

// Test your code by modifying these values
guys its not working plz help

hey guys can anybody help me
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:43
@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
shashankspecter99
@shashank1999coder
Jul 09 2017 15:47

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

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

return "NotFound";

}
// Test your code by modifying these values

tried this one too not yet working
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:47
@shashank1999coder how did you call the function? myObj("gift");
@shashank1999coder
function checkObj(checkProp) {
}
// 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
shashankspecter99
@shashank1999coder
Jul 09 2017 15:49
but i not showing result for "gift"
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:51
shashankspecter99
@shashank1999coder
Jul 09 2017 15:51

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

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

}
// Test your code by modifying these values

Ogundele Olumide
@Lumexralph
Jul 09 2017 15:51
@shashank1999coder the initial code you had, post it
@shashank1999coder checkProp is a parameter and not a string
@shashank1999coder if (myObj.hasOwnProperty(checkProp))
shashankspecter99
@shashank1999coder
Jul 09 2017 15:52
thank you @Lumexralph
CamperBot
@camperbot
Jul 09 2017 15:52
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
@shashank1999coder but I still like the one you did using ternary operator
shashankspecter99
@shashank1999coder
Jul 09 2017 15:53
@Lumexralph hmm
Ogundele Olumide
@Lumexralph
Jul 09 2017 15:53
@shashank1999coder this
function checkObj(checkProp) {
}
// Test your code by modifying these values
checkObj("gift");
shashankspecter99
@shashank1999coder
Jul 09 2017 15:54
yaa
Kelechi Chinaka
@kelechy
Jul 09 2017 15:59
:wave: guys
@Lumexralph awfa baba
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:01
@kelechy Brotherly, I'm good, you?
Kelechi Chinaka
@kelechy
Jul 09 2017 16:02
fine @Lumexralph what are u currently working on
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:08
@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
function convertObjectToList(obj) {
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
@kelechy
Jul 09 2017 16:09
ok..nice ..books helps too @Lumexralph
yes i think so @Lumexralph
Eva Raymond
@elitenoire
Jul 09 2017 16:10
someone help me keep getting error of can't read push property of undefined
Kelechi Chinaka
@kelechy
Jul 09 2017 16:12
@Lumexralph i need to learn OOP
Stephen James
@sjames1958gm
Jul 09 2017 16:12
@elitenoire you need to return list from the anonymous function
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:13
@elitenoire because push returns the length of the array
Eva Raymond
@elitenoire
Jul 09 2017 16:14
it worked!!!
thanks, thought I tried that earlier but didn't work.
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:15
@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
i'm gradually getting the hang on using the reduce method
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:16
@elitenoire cool
Stephen James
@sjames1958gm
Jul 09 2017 16:19
@Lumexralph Yeah. been a crazy off season
Kelechi Chinaka
@kelechy
Jul 09 2017 16:19
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
create a instance of person first...?
var bob = new Person()
bob.greet........()
Ogundele Olumide
@Lumexralph
Jul 09 2017 16:21
@sjames1958gm and Conte is going ballistic
aRtoo
@artoodeeto
Jul 09 2017 16:24
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 @artoodeeto just rebuild the URL string. create it from parts then exchange this part Kelechi Chinaka @kelechy Jul 09 2017 16:25 ok @moigithub aRtoo @artoodeeto Jul 09 2017 16:25 @sjames1958gm hmm. right. let me try. Ogundele Olumide @Lumexralph Jul 09 2017 16:26 @kelechy all this Class stuff JS is doing to please Class-oriented programming language developers Dan Couper @DanCouper Jul 09 2017 16:26 That's basically every widely-used language to be fair though Ogundele Olumide @Lumexralph Jul 09 2017 16:27 @DanCouper no argument about that Dan Couper @DanCouper Jul 09 2017 16:27 • better than the 1001 various class pattern boilerplate crap that came before. 😊 Ogundele Olumide @Lumexralph Jul 09 2017 16:28 @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 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 Second one is shorter First one is useful Kelechi Chinaka @kelechy Jul 09 2017 16:30 yea..for a prototypal language, the idea of classes in js is really confusing too @Lumexralph Stephane @overmelo Jul 09 2017 16:30 why am i not having the same result? @DanCouper Dan Couper @DanCouper Jul 09 2017 16:30 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 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 @kelechy but I think it's good for convention though Dan Couper @DanCouper Jul 09 2017 16:32 this.raceName isn't a thing @kelechy Kelechi Chinaka @kelechy Jul 09 2017 16:33 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 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 my code isn't working yet maybe you guys have a hint Ogundele Olumide @Lumexralph Jul 09 2017 16:34 @kelechy when you constructed your Class Person raceName was not a property Stephane @overmelo Jul 09 2017 16:35 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 @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 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 @Lumexralph thanks, i will try to figure this out CamperBot @camperbot Jul 09 2017 16:39 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 @DanCouper @kelechy or That's all!! :smile: Dan Couper @DanCouper Jul 09 2017 16:47 😊 Kelechi Chinaka @kelechy Jul 09 2017 16:48 lol aRtoo @artoodeeto Jul 09 2017 17:22 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 i got frozen browser because of infinite loop how can i fix it? pls help Nathaniel Suchy @nsuchy Jul 09 2017 17:40 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 @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 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 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 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 @alpox do you think find won't do a form of looping ? alpox @alpox Jul 09 2017 17:53 @Lumexralph As i said, it DOES loop ;-) you cannot come around that here Ogundele Olumide @Lumexralph Jul 09 2017 17:53 @alpox :laughing: alpox @alpox Jul 09 2017 17:54 @nsuchy Well you would usually go with abstracted methods for looping like .find as i did Nathaniel Suchy @nsuchy Jul 09 2017 17:54 Ok alpox @alpox Jul 09 2017 17:54 @nsuchy I use direct loops like for loops almost never Nathaniel Suchy @nsuchy Jul 09 2017 17:54 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 Just in a few cases where they really make sense Ogundele Olumide @Lumexralph Jul 09 2017 17:54 @alpox was just thinking about what @nsuchy said, maybe there'll be better algorithms though Nathaniel Suchy @nsuchy Jul 09 2017 17:54 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 @Lumexralph I'm open to suggestions :D Nathaniel Suchy @nsuchy Jul 09 2017 17:55 @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 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 @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 @alpox i know there'll be some mathematicians would've cooked up some stuffs Nathaniel Suchy @nsuchy Jul 09 2017 17:56 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 @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 @alpox hmmm..... interesting alpox @alpox Jul 09 2017 17:57 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 Hey guys i am stuck at this challenge - Iterate through an array with a for loop. Nathaniel Suchy @nsuchy Jul 09 2017 17:58 @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 @alpox enlightening, is B+ also binary search ? Ashish Kumar Sangwan @KsangwanA Jul 09 2017 17:58 I am having problem in understanding the logic behind the length property = -1. Ogundele Olumide @Lumexralph Jul 09 2017 17:59 @KsangwanA your question is not clear alpox @alpox Jul 09 2017 17:59 @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 @alpox cool, just wanted be cleared @alpox thanks CamperBot @camperbot Jul 09 2017 18:00 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 @Lumexralph Frank McCroy @fmccroy Jul 09 2017 18:02 @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 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 @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 @alpox special memory-trees with nodes on several tree levels more like DOM tree Ashish Kumar Sangwan @KsangwanA Jul 09 2017 18:05 @ Frank McCroy I still don't get it. Can you please give an example. alpox @alpox Jul 09 2017 18:06 @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 @alpox just painting an analogy :wink: Frank McCroy @fmccroy Jul 09 2017 18:09 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 @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 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 @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 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 Ookkk now i get it . Ogundele Olumide @Lumexralph Jul 09 2017 18:16 @vishalnagda1 !isNaN(index) Ashish Kumar Sangwan @KsangwanA Jul 09 2017 18:17 @fmccroy thanks CamperBot @camperbot Jul 09 2017 18:17 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 @Gurpreet3131 I am not sure but try pug. Ashish Kumar Sangwan @KsangwanA Jul 09 2017 18:17 @ Vishal Nagda @vishalnagda1 Jul 09 2017 18:17 Yes because of the !isNaNbut why ? Moisés Man @moigithub Jul 09 2017 18:17 @Gurpreet3131 use a template system like pug/handlebars/ejs Ashish Kumar Sangwan @KsangwanA Jul 09 2017 18:17 @alexanderkopke thanks. CamperBot @camperbot Jul 09 2017 18:17 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 @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 Saif Ur Rahman @saifsmailbox98 Jul 09 2017 18:20 @Gurpreet3131 do you want to change the content based on what URL is requested? Gurpreet SIngh @Gurpreet3131 Jul 09 2017 18:21 yes Saif Ur Rahman @saifsmailbox98 Jul 09 2017 18:21 @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 @Lumexralph thank you :) CamperBot @camperbot Jul 09 2017 18:21 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 @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 @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 @moigithub can you give me a brief prview of what ejs or pug will do? Saif Ur Rahman @saifsmailbox98 Jul 09 2017 18:23 also there is a getting started guide on ejs here http://ejs.co/ Gurpreet SIngh @Gurpreet3131 Jul 09 2017 18:25 I will have a look at it Moisés Man @moigithub Jul 09 2017 18:26 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 .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 wow did ejs update their site or is it a new one? Gurpreet SIngh @Gurpreet3131 Jul 09 2017 18:35 @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 @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 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 @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 @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 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 @Gurpreet3131 create a <p> tag with <p>{{content}}</p>, in your layout file. Gurpreet SIngh @Gurpreet3131 Jul 09 2017 18:52 I have created it AlliBun @AlliBun Jul 09 2017 18:52 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 @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 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 thank you so much @SkyC0der CamperBot @camperbot Jul 09 2017 19:00 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 @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 Thanks @saifsmailbox98 CamperBot @camperbot Jul 09 2017 19:20 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 @Thayyebsalim :+1: yw Innocent Tauzeni @Telthem89 Jul 09 2017 19:22 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 @Hello911 How to make a rectangle into a arrow shape just using CSS code? Moisés Man @moigithub Jul 09 2017 19:52 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 @moigithub I was thinking of building a pentagon using CSS Jemal Mohammed @JemalMoha Jul 09 2017 19:54 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 @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 @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 ...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 @Manish-Giri ok, but what do ypu think us missing the code not to work John @AnonymousLords Jul 09 2017 19:59 :point_up: July 9, 2017 8:39 AM @sjames1958gm :thumbsup: Jemal Mohammed @JemalMoha Jul 09 2017 19:59 it is printio o,l,l Manish Giri @Manish-Giri Jul 09 2017 20:02 @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 great , it makes sense! @Manish-Giri thank you! CamperBot @camperbot Jul 09 2017 20:06 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 :+1: aRtoo @artoodeeto Jul 09 2017 20:08 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 @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 @John-freeCodeCamp the button sir. i want close to the 122 @John-freeCodeCamp its under the text. John @AnonymousLords Jul 09 2017 20:13 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 Hello John @AnonymousLords Jul 09 2017 20:16 You did the whole row thing weird Dovydas Stirpeika @Giveback007 Jul 09 2017 20:16 hey peeps do you guys know anything about ios safari browser compatability? John @AnonymousLords Jul 09 2017 20:16 Each should have its own div with "col-md-6" or something Dovydas Stirpeika @Giveback007 Jul 09 2017 20:16 and it's driving me crazy John @AnonymousLords Jul 09 2017 20:17 @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 the header doesn't obey 100vw and heigh on ios devices John @AnonymousLords Jul 09 2017 20:18  <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 @John-freeCodeCamp yea i have that. one big row John @AnonymousLords Jul 09 2017 20:20 Now does it all equal up to 12? aRtoo @artoodeeto Jul 09 2017 20:20 @John-freeCodeCamp yea. wait. send it to you John @AnonymousLords Jul 09 2017 20:20 Its a total of 13 aRtoo @artoodeeto Jul 09 2017 20:20 @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 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 @John-freeCodeCamp thats the parent div @John-freeCodeCamp see the the inner row? John @AnonymousLords Jul 09 2017 20:23 Why is temperature inside of the row? Its not even closed off Ayush Mahajan @ay2306 Jul 09 2017 20:23 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 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 @John-freeCodeCamp nvm sir. thnk John @AnonymousLords Jul 09 2017 20:25 @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 so no solution then? John @AnonymousLords Jul 09 2017 20:26 rooms /rooms CamperBot @camperbot Jul 09 2017 20:26 #### 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 @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 guys.. help me please John @AnonymousLords Jul 09 2017 20:28 Im not sure about that, but ask this room https://gitter.im/FreeCodeCamp/FreeCodeCamp James Patrick Kerrane @jamesjpk123 Jul 09 2017 20:55 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 @kelechy Jul 09 2017 20:58 use join @jamesjpk123 James Patrick Kerrane @jamesjpk123 Jul 09 2017 21:00 Thanks @kelechy it worked! CamperBot @camperbot Jul 09 2017 21:00 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 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 If you link your account and ping me @kelechy, i can give you cookies @kelechy thanks again! CamperBot @camperbot Jul 09 2017 21:01 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 I was wondering if I could get some help with my code camp challenge? John @AnonymousLords Jul 09 2017 21:16 @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 @John-freeCodeCamp aihgt ill try sir. thans John @AnonymousLords Jul 09 2017 21:19 @artoodeeto type "thanks @person" or "danke @person" CamperBot @camperbot Jul 09 2017 21:19 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 function fearNotLetter(str) { return string.fromCharCode(); } fearNotLetter("abce"); I need help John @AnonymousLords Jul 09 2017 21:20 @artoodeeto You may also have to do "margin-top: -1%;" and "margin-bottom" Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:21 @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 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 @saifsmailbox98 what do I do next? monkeyfingerz @monkeyfingerz Jul 09 2017 21:25 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 @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 @saifsmailbox98 So How do I check to see if the sequence is maintained or not? Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:28 @moellennium you need to build the logic, try charCodeAt() to get the charCode of the letters. monkeyfingerz @monkeyfingerz Jul 09 2017 21:29 Why can't i use the wiki api? on codepen moellennium @moellennium Jul 09 2017 21:31 @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 @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 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 @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 @monkeyfingerz where do you live mate monkeyfingerz @monkeyfingerz Jul 09 2017 21:33 washington @MikailSeremet AlliBun @AlliBun Jul 09 2017 21:34 thank you @Manish-Giri CamperBot @camperbot Jul 09 2017 21:34 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 :+1: moellennium @moellennium Jul 09 2017 21:37 @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 @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 @saifsmailbox98 how do I do that? Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:39 @moellennium do you want a solution? moellennium @moellennium Jul 09 2017 21:39 @saifsmailbox98 yes Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:41 @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 hi guys. how do you use herokuapp to run on codepen?? Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:42 @artoodeeto on codepen? moellennium @moellennium Jul 09 2017 21:43 @saifsmailbox98 thanks CamperBot @camperbot Jul 09 2017 21:43 moellennium sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles: :cookie: 742 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98 aRtoo @artoodeeto Jul 09 2017 21:43 @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 @artoodeeto try building locally, or use another api. aRtoo @artoodeeto Jul 09 2017 21:44 @saifsmailbox98 im tired to re create a weather app again. Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:44 @artoodeeto share your pen please. aRtoo @artoodeeto Jul 09 2017 21:45 @saifsmailbox98 k sir. wait @saifsmailbox98 @saifsmailbox98 https://codepen.io/artoo/pen/bRmrzz Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:46 @artoodeeto try this https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather? aRtoo @artoodeeto Jul 09 2017 21:47 @saifsmailbox98 where should i put this?? Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:47 @artoodeeto var api = 'https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?'; aRtoo @artoodeeto Jul 09 2017 21:48 @saifsmailbox98 doenst work sir Luis @Rushh Jul 09 2017 21:48 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 @artoodeeto Allow location, it's loading the weather data for me aRtoo @artoodeeto Jul 09 2017 21:50 @saifsmailbox98 allow where? Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:50 @artoodeeto try refrshing, then allow location on the top left aRtoo @artoodeeto Jul 09 2017 21:51 @saifsmailbox98 codepen rigt?? doesnt work Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:51 Alexander Køpke @alexanderkopke Jul 09 2017 21:51 @monkeyfingerz in the url change to this: &format=json& and below change to this: dataType: "jsonp" aRtoo @artoodeeto Jul 09 2017 21:52 @saifsmailbox98 ohh. thanks bro. ijust need to clearn the ocation CamperBot @camperbot Jul 09 2017 21:52 artoodeeto sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles: :cookie: 743 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98 Luis @Rushh Jul 09 2017 21:53 Nvm, solved it Saif Ur Rahman @saifsmailbox98 Jul 09 2017 21:55 @artoodeeto :+1: Saikat-Sinha @Saikat-Sinha Jul 09 2017 22:01 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 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 @monkeyfingerz yeah but that shouldn't be a gap in your url & &.. just json&search= monkeyfingerz @monkeyfingerz Jul 09 2017 22:07 @alexanderkopke thank you that was pretty frustrating CamperBot @camperbot Jul 09 2017 22:07 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 @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
and... if an ID then need a # instead
moellennium
@moellennium
Jul 09 2017 22:10
@saifsmailbox98 beg means beginning right?
Luis
@Rushh
Jul 09 2017 22:11
Any idea why this returns 4 instead of 3? Solved it with forEach but not exactly sure why this approach failed
function getLengthOfShortestElement(arr) {
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
@Rushh @Rushh because the first parameter to the reduce function is the accumulated value not the next value
Luis
@Rushh
Jul 09 2017 22:29
What do you mean?
Oh so it should be function(shortest, value)...
or (shortest, str)
Stephen James
@sjames1958gm
Jul 09 2017 22:30
@Rushh yes.
John
@AnonymousLords
Jul 09 2017 22:30
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
@Rushh
Jul 09 2017 22:30
Thanks! @sjames1958gm
CamperBot
@camperbot
Jul 09 2017 22:30
rushh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8027 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John
@AnonymousLords
Jul 09 2017 22:31


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
@John-freeCodeCamp look at the comment it says where to assign 5 to oopsGlobal
John
@AnonymousLords
Jul 09 2017 22:32
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
oopsGlobal = 5; this line is supposed to be inside fun1() {}
John
@AnonymousLords
Jul 09 2017 22:32
Am i doing a math equation? Like oopsGlobal += myGlobal +- oopsGlobal
Ohhh
So is this correct


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
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
It still worked teh other way around?
Stephen James
@sjames1958gm
Jul 09 2017 22:34
@John-freeCodeCamp seems the tests are not sufficient in detecting that case
John
@AnonymousLords
Jul 09 2017 22:35
SHould i report it as a bug?
@sjames1958gm ello?
@sjames1958gm Anyways thanks
CamperBot
@camperbot
Jul 09 2017 22:38
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
@moellennium yes
John
@AnonymousLords
Jul 09 2017 22:41
/bug