These are chat archives for FreeCodeCamp/HelpFrontEnd

13th
Oct 2017
Toni Shortsleeve
@KoniKodes
Oct 13 2017 00:07
@Petterandre Don't be discouraged. I did the same thing where I fixed it but it wouldn't stay fixed :-) You'll get it there.
Long Nguyen
@longnt80
Oct 13 2017 00:46
anyone experience with react router?
https://longnt80.github.io/punk-beer/
here's my website. When I click to view one product's detail, I want to hit thebrowser's Back button and go back to the same page (pagination).
RIght now, it just goes back to the first page.
Aron Ciruela
@auricless
Oct 13 2017 03:46
what are the different weather aside from "Clouds" (which I am getting) from the FCC Weather API?
there's no documentation or such for it so I need some help.
Amit Patel
@AmitP88
Oct 13 2017 03:55
hey guys, I'm wroking on my tile swap function in my match 3 game and I need a little help. I've made an empty array called swap_container that will hold a max of two clicked tiles to be swapped. I'm now working on conditions that will exclude a tile from being added to the array if the 2nd clicked tile is: 1.) the same tile as the first one clicked, 2.) not immediately next to the 1st clicked tile in any direction (left, top, right, bottom). I'm having trouble getting the 2.) condition to work. Please, any help will be highly appreciated
https://codepen.io/AmitP88/pen/pWyaNY
alpox
@alpox
Oct 13 2017 05:44
@auricless the documentation is at
Openqeatherapi. Because thats what the fcc weather api uses behind the acenes
Scenes*
Sorry for the bad writing, im on the phone :D
SL0TR
@SL0TR
Oct 13 2017 07:04

Need help!
https://codepen.io/SL0TR/pen/aLjyJz?editors=0111

When I'm adding an attribute(id) with JavaScript on the canvas tag it isn't showing up.
But if it's put manually then it shows

The id shows up in console but the element isn't visible.
Please review and give the feedback on my first project in FCC
Tribute page
Bharathy
@aBharathy
Oct 13 2017 09:47
should I post the link somewhere to get the feedback?Please guide me
Fabien SHAN
@X140hu4
Oct 13 2017 09:55
@aBharathy Just a few things I would change personally, these are not necessarily "best practices":
  • keep the files clean of unused blocks and add comments
  • use shorthands in CSS: .thick-green-border's border styling could be reduced to two lines instead of four
  • ID is unique, you are using it twice in the html (#header1)
@aBharathy What was the most difficult part for you?
Bharathy
@aBharathy
Oct 13 2017 10:11
@X140hu4 Responsiveness to images
heroiczero
@heroiczero
Oct 13 2017 10:12
@aBharathy Well nice job on the :+1: Tribute :)
MomchilDeus
@MomchilDeus
Oct 13 2017 10:13
@khaduch Hey there, https://codepen.io/MomchilDeus/pen/NaMzZj this is the link
Bharathy
@aBharathy
Oct 13 2017 10:13
@heroiczero I would appreciate the suggestions for improvement
@X140hu4 Thank you so much for the efforts to let me know the improvements to bedone
CamperBot
@camperbot
Oct 13 2017 10:14
abharathy sends brownie points to @x140hu4 :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @x140hu4 |http://www.freecodecamp.com/x140hu4
heroiczero
@heroiczero
Oct 13 2017 10:29
@MomchilDeus would be nice if you could move the timeline by clicking and dragging on mousedown or something . Other than that, it is really well done. :)
Petterandre
@Petterandre
Oct 13 2017 10:43
Does anyone here have any idea why my reset button ruins the game? https://codepen.io/ImNoroz/pen/YrNpmq?editors=0112
Johnny
@JohnnyBizzel
Oct 13 2017 11:27
@Petterandre Why does it say "Oops try again" when I get it right?
Petterandre
@Petterandre
Oct 13 2017 11:27
I'm currently testing something :)
Trying to make it so that instead of having to enter the entire sequence before being told you are wrong, I want to catch it when you enter it wrong
Johnny
@JohnnyBizzel
Oct 13 2017 11:29
@Petterandre So the reset is working now?
Petterandre
@Petterandre
Oct 13 2017 11:29
Indeed
Dan Couper
@DanCouper
Oct 13 2017 11:29
@Petterandre what do you mean by ruins the game? It's working as I'd expect it to afaics, what should the expected behaviour be?
Ah nm, you fixed it :smile:
Johnny
@JohnnyBizzel
Oct 13 2017 11:29
Riiiiight
Thanks for letting us know
Petterandre
@Petterandre
Oct 13 2017 11:29
Got the reset fixed, but trying the catch now
Johnny
@JohnnyBizzel
Oct 13 2017 11:30
:|
Petterandre
@Petterandre
Oct 13 2017 11:30
Got too excited in fixing it that I forgot to let you know (got help from the other channel)
tunnelvision, haha
Chris Cullen
@123xylem
Oct 13 2017 12:22

Hey guys.. Can u help me get the title and caption to come up a few lines on this site?
https://www.rosalievillagebarber.com
So far Ive used inspect and copied the selector it shows me for the caption but the thing just wont move!
Heres my code so far:

#main-slider > div.bx-wrapper > div.bx-viewport > div > div:nth-child(1) > div.slider-caption{padding-top:-30rem;}

So can you get the title and caption to move up the page?

Cheers
Marianissimus
@Marianissimus
Oct 13 2017 12:34
@123xylem You don't need to go all the way up or down through the DOM tree to select that -
instead, just try selecting one of these classes: .slider-caption, .caption-title or .caption-description
Chris Cullen
@123xylem
Oct 13 2017 12:40
@Marianissimus well ive tried a few things and none have affected it
@Marianissimus actually thanks.. selecting just 2 classes did it!
CamperBot
@camperbot
Oct 13 2017 12:43
123xylem sends brownie points to @marianissimus :sparkles: :thumbsup: :sparkles:
:cookie: 446 | @marianissimus |http://www.freecodecamp.com/marianissimus
Marianissimus
@Marianissimus
Oct 13 2017 12:46
you're welcome
Cale Switzer
@Tennyx
Oct 13 2017 13:56
So I am starting to upload FCC projects to github. For example I just added calculator. I plan to eventually have the visual interface of it on my personal website with a link to the github. Should I just link ot the script that makes it run? Or should I also include the html and css I used?
Tom
@moT01
Oct 13 2017 14:24
@Tennyx if you give a link to the github, they can probly find the code
Cale Switzer
@Tennyx
Oct 13 2017 14:29
@moT01 so you think I should keep the html and css in there?
Tom
@moT01
Oct 13 2017 14:44
keep it where
Cale Switzer
@Tennyx
Oct 13 2017 14:47
in the repository
Tom
@moT01
Oct 13 2017 14:47
yes
Cale Switzer
@Tennyx
Oct 13 2017 14:47
aweomse, thanks @moT01
CamperBot
@camperbot
Oct 13 2017 14:47
tennyx sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 877 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
Oct 13 2017 14:47
im not quite sure how you want things set u
up
so i guess i don't know what you should keep where, ...but if you're putting projects on github, might as well put the whole project on there right
github pages is in the repo settings turn it on to allow you to check out a working version of the project hosted by github
my github is pretty decently organized if you want to check it out github.com/moT01
GabriRa
@GabriRa
Oct 13 2017 14:57
Hey, can someone help me With the React game oof life project
or Some video that explains what is he doing?
Tom
@moT01
Oct 13 2017 14:58
what who is doing
GabriRa
@GabriRa
Oct 13 2017 14:58
I have everything right I think, except the way of updating all the game
Tom
@moT01
Oct 13 2017 14:59
do you have a pen?
J.Chechelski
@SupaSaiyan
Oct 13 2017 15:03
Hello guys, fast question. I'm typing my first portfolio. Shall I use CSS variables? IE doesn't support. What do you think?
Tom
@moT01
Oct 13 2017 15:04
css variables?
Markus Kiili
@Masd925
Oct 13 2017 15:05
@SupaSaiyan You should make it so that it also works in IE.
GabriRa
@GabriRa
Oct 13 2017 15:06
Me? I am doing it here
https://codepen.io/GabriRa/pen/XeqXmX but I diont get hw should I update everything
Tom
@moT01
Oct 13 2017 15:08
do you know the rules?
you need to make an algorithm to find out how many neighbors each cell has
GabriRa
@GabriRa
Oct 13 2017 15:10
Its done, with some conditions so it takes only good neighbors
but I dont know how to update every cell, let me comment more my code
Tom
@moT01
Oct 13 2017 15:11
good neighbors
? ha, the bad neighbors get shunned from the neighborhood?
Jose Diaz
@jsd540
Oct 13 2017 15:12
Good morning all, I want to create an array of arrays - stuff[{'name':name, 'live':live},{'name':name, 'live':live},{'name':name, 'live':live}] but I'm getting 0:{'name':name, 'live':live}, 1:{'name':name, 'live':live}, etc my code is var stuff = []; stuff.push({
'name':name,
'live':live
})
What am I doing wrong?
Tom
@moT01
Oct 13 2017 15:13
@jsd540 you're making an array of objects there
GabriRa
@GabriRa
Oct 13 2017 15:13
the first row should not use the state of the neighbors that are above, as they don't have one
Tom
@moT01
Oct 13 2017 15:15
@GabriRa it's not supposed to be playing yet, is it?
GabriRa
@GabriRa
Oct 13 2017 15:16
I dont know hoe to make it start
Tom
@moT01
Oct 13 2017 15:18
is that a question?
Jose Diaz
@jsd540
Oct 13 2017 15:18
@moT01 but its showing up as an array for each user and the length for stuff is always 0
GabriRa
@GabriRa
Oct 13 2017 15:19
no
It should be running
but i have done something wrong, so it does not starts
or rerender the cell
Tom
@moT01
Oct 13 2017 15:20
change the state to the new array @GabriRa
GabriRa
@GabriRa
Oct 13 2017 15:21
my god
I think you are right
Tom
@moT01
Oct 13 2017 15:21
@jsd540 stuff should have 3 length i think
Jose Diaz
@jsd540
Oct 13 2017 15:23
so var stuff = new.array(); ?
@jsd540
i think it's getting stuck looking for variables named live and name
need to make them strings in the object, or create variables with those names
GabriRa
@GabriRa
Oct 13 2017 15:25
Why when I use setState it doesn't triggers ComponentDidMount again?
Jose Diaz
@jsd540
Oct 13 2017 15:26
thats what I want to end up with but it seems to be pushing to individual arrays
Tom
@moT01
Oct 13 2017 15:26
@GabriRa i dont think it's supposed to trigger that
@jsd540 check it again
Marc
@MWBauer
Oct 13 2017 15:30
Anyone have a moment?
Tom
@moT01
Oct 13 2017 15:31
@MWBauer whats up
Marc
@MWBauer
Oct 13 2017 15:32
I'm working on the Random Quote Generator. Once I've gone and pulled a random quote from the web, it needs to be displayed. Do I need a special field for that to display in, or make a button and have the message display there?
Tom
@moT01
Oct 13 2017 15:33
@GabriRa i dont know spanish (i think that's spanish), so it's tough for me to find out what's going wrong there, but there should be single array that you map to the html in the return() and then in the function to update the grid you should change the state at the end, and it will automatically update the screen
pretty sure that's how i did it
@MWBauer make an html element to put it in
and use .html to put the quote in it
(if you're using jquery)
Marc
@MWBauer
Oct 13 2017 15:35
thx
@moT01 thanks
CamperBot
@camperbot
Oct 13 2017 15:36
sorry mot01, you can't send brownie points to yourself! :sparkles: :sparkles:
Jose Diaz
@jsd540
Oct 13 2017 15:41
@moT01 yep still get 0 length, and [] in the console...
Marc
@MWBauer
Oct 13 2017 15:42
What's the newest version of HTML?
Tom
@moT01
Oct 13 2017 15:42
that's not what i got in the example i made @jsd540, do you have code i can see
5 @MWBauer
i think
Marc
@MWBauer
Oct 13 2017 15:43
thx
Tom
@moT01
Oct 13 2017 15:43
click my name
Jose Diaz
@jsd540
Oct 13 2017 15:49

// list of active users from twitch

var userNameList = ['riotgames','syndicate','summit1g','esl_csgo',
'esltv_cs','nightblue3','imaqtpie','lirikk','lirik','sodapoppin',
'meclipse','cretetion', 'shroud','officialbjergsen','wolves_bjergsen',
'theoriginalweed','joshog','freecodecamp','Tsm_dyrus','dyrus','gosu',
'dreamhackcs','timthetatman','ESL_SC2', 'captainsparklez','goldglove','boxbox',
'speeddemosarchivesda','gamesdonequick','sgdq','trick2g','nl_kripp','castro_1021',
'swiftor','c9sneaky','storbeck', 'doublelift_renamed300203','doublelift',
'drdisrespectlive','OgamingSC2', 'sivhd','iijeriichoii','faceittv','Faceit',
'faker','tsm_theoddone','izakooo','pewdiepie','eleaguetv','amazhs','Voyboy',
'cohhcarnage','%63ohhcarnage','pashabiceps','anomalyxd','ungespielt',
'Tsm_doublelift','mlg_live','mlg','trumpsc','trump','pgl','loltyler1',
'omgitsfirefoxx','kinggothalion','habathcx', 'thenadeshot','nadeshot',
'kittyplaysgames','kittyplays','yoda','stonedyooda','RobotCaleb', 'GiantWaffle',
'Gronkh','bobross','nick28t','noobs2ninjas', 'gassymexican','monstercat','cryaotic',
'montanablack88','a_seagull','m0e_tv','reckful','kaypealol','sovietwomble',
'ProfessorBroman','nickbunyun','nalcs1','starladder5','twitch','e3','tsm_bjergsen',
'forsenlol','yogscast','rewinside','zeeoon','legendarylea','markiplier',
'dansgaming','pokimane','froggen','olofmeister','towelliee','aphromoo',
'ninja','streamerhouse'];

// userNameList array size.

var size = userNameList.length;

$(document).ready(function(){

// active on click button

// $("button").click(function(){
//   $("button").removeClass("active");
//   $(this).addClass("active");
// });

// listen for a button click to call function

// iterate the userNameList array
// and get necessary data for each user

for(var i = 0; i < size; i++){

    // construct the url

    var user_name = userNameList[i];
    var user_url = 'https://wind-bow.gomix.me/twitch-api/users/';

    user_url += user_name + '?callback=?';

    $.getJSON(user_url, function (user_data) {

    var name = user_data.display_name;     // twitch streamer user name
    var name2 = user_data.name;            // twitch user name to be sent to isItLive
    var logo = user_data.logo;             // streamer logo image
    var bio = user_data.bio;            // streamer bio

    if (bio == null){ // handle null bio case
        bio = 'no bio available';
    }
    else{ // if bio is too long limit size 
        bio = bio.substring(0,125) + "...";
    }
    // send data to isItLive

    isItLive(name, name2, logo, bio);

    });        
}

});

// this function finds out weather the streamer is
// currently live or if they are off the air.

function isItLive(name, name2, logo, bio){

var user_stream_url = 'https://www.twitch.tv/' + name2; // cunstruct user stream url

// construct url

var stream_url = 'https://wind-bow.gomix.me/twitch-api/streams/';

stream_url += name2 + '?callback=?';

$.getJSON(stream_url, function(liveOrNot){

    // if the streamer is off the air liveOrNot returns null
    // else streamer is currently on the air

    if (liveOrNot.stream != null){

    console.log(name + "  " + bio + " On-line now!");


    }
    else{

     console.log(name + " " + bio + " Off-line!");

    }

});

};

Tom
@moT01
Oct 13 2017 15:52
so your computer can run through code really fast, ...that for loop takes like no time. A getJSON request, however, takes a little more time
so why you aren't able to fill your array is cause the request hasn't returned any values before you try and push it to the array
Kaz Baig
@kbaig
Oct 13 2017 15:53
@MWBauer 5 but it is generally assumed that this is the final 'version' -- features will get added over time but they won't increment the version number. This is evidenced by the doctype declaration being simply <!DOCTYPE html> as opposed to <!DOCTYPE html5>
Tom
@moT01
Oct 13 2017 15:54
@jsd540 pretty sure that's the problem... change your for loop to a forEach loop
Jose Diaz
@jsd540
Oct 13 2017 15:54
ah that makes sense, is there a way to sync so the loop waits for a reply
Marc
@MWBauer
Oct 13 2017 15:58
I need guidance.
Tom
@moT01
Oct 13 2017 15:58
@jsd540 that won't be the last time you come across that problem, you might want to figure out how to debug it, i would have console.log the userNameList[i], and also console log the returned data
Marc
@MWBauer
Oct 13 2017 15:58
How do I get text from a website for the Random Quote Generator?
Kaz Baig
@kbaig
Oct 13 2017 15:59
@MWBauer You would need to find a quote API
Tom
@moT01
Oct 13 2017 15:59
and you would see a list of all the names before any data @jsd540
ehutchllew
@ehutchllew
Oct 13 2017 16:00
@jsd540 I haven't done a RESTful call inside a for loop in a while, but you could try creating a promise, then once you get a response from the service you resolve it, and I believe that will sort of "pause" the for loop iterations.
@jsd540 or wrap your RESTful API call inside of an IFFE.
Jose Diaz
@jsd540
Oct 13 2017 16:03
@moT01 @ehutchllew thanks guys, I'm gonna re-think this, at least I know what the problem is now...
CamperBot
@camperbot
Oct 13 2017 16:03
jsd540 sends brownie points to @mot01 and @ehutchllew :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @ehutchllew |http://www.freecodecamp.com/ehutchllew
:cookie: 878 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
Oct 13 2017 16:04
@jsd540 that forEach loop should fix it, should just need to swap out one line
but, there's other ways as well
ehutchllew
@ehutchllew
Oct 13 2017 16:08
@jsd540 Yeah try what @moT01 is saying, the forEach looks at the actual value in the indices of the array rather than a 'counter'.
Jose Diaz
@jsd540
Oct 13 2017 16:10
@ehutchllew @moT01 yes, I will try a for each... Dear diary today I learned about for each :) Thanks guys.
CamperBot
@camperbot
Oct 13 2017 16:10
jsd540 sends brownie points to @ehutchllew and @mot01 :sparkles: :thumbsup: :sparkles:
api offline
api offline
B
@B-keen
Oct 13 2017 16:26
'''
CamperBot
@camperbot
Oct 13 2017 16:26
:bulb: to format code use backticks! ``` more info
B
@B-keen
Oct 13 2017 16:47
```
return collection[5439].album;
Ken Haduch
@khaduch
Oct 13 2017 17:03
@MomchilDeus - looks good :point_up: October 13, 2017 6:13 AM - my last nit-pick - I would like to have either a set of links at the bottom for the different sections, or the nav button frozen to the top of the screen when you scroll up? I know that I'm just being lazy... the site looks great. I really like that timeline presentation!
Jay Vora
@jayvora92
Oct 13 2017 17:33

hello everyone I have a quick question. any help would be appreciated.
right now

else if({{Page Path}}.indexOf("/xyz/abc") >= 0) return "test";  
but actually i want  to return "test" on /xyz/abc/#employer.

how do i add that hash. If it helps I already have a variable URL fragment = "employers". what would be the best way to add it

Roge
@RogeMateos
Oct 13 2017 17:53
hello
i need some help with flex box
anyone thatcan help me please
alteducation
@alteducation
Oct 13 2017 17:54
@RogeMateos yeah
Roge
@RogeMateos
Oct 13 2017 17:54
hey @alteducation how are you
alteducation
@alteducation
Oct 13 2017 17:55
@RogeMateos tell me i will help you with your flexbox isuue
@RogeMateos do you have it on codepen?
Roge
@RogeMateos
Oct 13 2017 17:56
there is something i don’t understand here , there is section class main as a container flexbox then i have article class featured and caside class sidebar
Tom
@moT01
Oct 13 2017 17:56
@jayvora92 what's the hash for, can you put it in the variable
"#employers"
this is the example
B
@B-keen
Oct 13 2017 17:56
return collection[5439].album;
Roge
@RogeMateos
Oct 13 2017 17:57
whati dont understand is featured and aside does not have width
B
@B-keen
Oct 13 2017 17:57
I was wondering in the record collection challenge why the above code is not returning anything
Roge
@RogeMateos
Oct 13 2017 17:57
what makes them behave with different widths
Screen Shot 2017-10-13 at 19.07.24.png
Screen Shot 2017-10-13 at 19.07.24.png
Screen Shot 2017-10-13 at 19.07.24.png
alteducation
@alteducation
Oct 13 2017 18:00
@RogeMateos yeah I just checked the featured has a flex value of 2 and aside has a value of 1
@RogeMateos that means they share the space in that ratio
Ken Haduch
@khaduch
Oct 13 2017 18:00
@B-keen - is it not returning anything or not returning the correct thing to pass the challenge?
alteducation
@alteducation
Oct 13 2017 18:01
@khaduch that is featured takes up 2/3 space and aside takes 1/3 space
@RogeMateos that is featured takes up 2/3 space and aside takes 1/3 space
Roge
@RogeMateos
Oct 13 2017 18:01
ok just unlock 2 and 1 and same behavour
unclick
alteducation
@alteducation
Oct 13 2017 18:02
@RogeMateos if you change the featured flex value to 5 it will take up more space
Ken Haduch
@khaduch
Oct 13 2017 18:03
@B-keen - that could be returning the value of the property album, if there is one. But for record collection, you want to just return collection, the entire modified object.
Jay Vora
@jayvora92
Oct 13 2017 18:04
@moT01 yes. I used and condition with the url
its working now
alteducation
@alteducation
Oct 13 2017 18:04
@RogeMateos flex value is dynamic if aside is 1 and featured is 1 then it will be 50 50
if aside is 1 and featured is 4 it will be 20: 80
refesh and check again and you will see what i mean
now you dont have 2 and 4
where is taking the width from
alteducation
@alteducation
Oct 13 2017 18:06
@RogeMateos if you dont specify any flex value it will take up the width required to fit the content
Roge
@RogeMateos
Oct 13 2017 18:07
so in this case the width is 90 per cent of the body?
and why is featured taking more width than sidebar?
alteducation
@alteducation
Oct 13 2017 18:08
@RogeMateos because featured has more content the width is decided by the content inside it. aside only requires that much width to fit its contens
@RogeMateos if you dont specify flex values it will take up the width required to fit content
Roge
@RogeMateos
Oct 13 2017 18:11
ok i think i understand , and what is happening is the feature image is filling more content there and making FEATURE div bigger than ASIDE
alteducation
@alteducation
Oct 13 2017 18:11
@RogeMateos yeah
Roge
@RogeMateos
Oct 13 2017 18:11
ok that is clear now
many thanks for your help
i really appreciate your time
alteducation
@alteducation
Oct 13 2017 18:12
@RogeMateos you can override that by assigning your own value :)
@RogeMateos no issues.
Roge
@RogeMateos
Oct 13 2017 18:12
yes i understand
buiphuking
@buiphuking
Oct 13 2017 18:40
anyone has experience with httrack here, i want to ask something....................
B
@B-keen
Oct 13 2017 18:46
@khaduch it's returning the entire collection
Stephen James
@sjames1958gm
Oct 13 2017 20:23
@B-keen you are supposed to update and return the entire collection from the instructions . . .
Your function must always return the entire collection object.
Ashwin
@ashwins93
Oct 13 2017 20:45

https://codepen.io/ashwins93/full/qPrBRE/

I just completed my markdown previewer project. I am just interested to know if this could be completed without __dangerouslySetInnerHTML. And btw where are you guys learning React from? I learned through codecademy but i'm not sure if i really understand everything, can you give me some pointers?

Tomáš Dvořák
@Deepress
Oct 13 2017 20:47
Hi guys, anyone tried to override bootstrap 4 variables in sass ? they're all set as !default so i can do exactly nothing :/
Stephen James
@sjames1958gm
Oct 13 2017 20:48
@ashwins93 Not sure you can do that without that function. Maybe in React 16, but not sure. I learned react from Udemy course.
Ashwin
@ashwins93
Oct 13 2017 20:49
@sjames1958gm Will check out the course, thanks!
CamperBot
@camperbot
Oct 13 2017 20:49
ashwins93 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8550 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Oct 13 2017 20:49
@ashwins93 There is an instructor Andrew Mead that I recommend.
Vamshi Gudipati
@vamshikrishna144
Oct 13 2017 20:51
@ashwins93 haven't really gone thru your code but here is my answer on stackO
Ashwin
@ashwins93
Oct 13 2017 20:52
@vamshikrishna144 Yeah i came across this when i was googling
i used html-react-parser from npm
Vamshi Gudipati
@vamshikrishna144
Oct 13 2017 20:53
that should to the trick too
Ashwin
@ashwins93
Oct 13 2017 20:53
But internally it does use dangerouslySetInnerHtml
My doubt is purely academical btw
Vamshi Gudipati
@vamshikrishna144
Oct 13 2017 20:55
Then use this
this doesnt use dangerouslySetInnerHtml
Ashwin
@ashwins93
Oct 13 2017 20:58
@vamshikrishna144 Thanks! this is exactly what i was looking for. I need to upgrade my googling skills, i wandered for a couple of hours
CamperBot
@camperbot
Oct 13 2017 20:58
ashwins93 sends brownie points to @vamshikrishna144 :sparkles: :thumbsup: :sparkles:
:cookie: 5 | @vamshikrishna144 |http://www.freecodecamp.com/vamshikrishna144
Ashwin
@ashwins93
Oct 13 2017 20:59
Next time i should check here first i guess
Vamshi Gudipati
@vamshikrishna144
Oct 13 2017 21:03
Haha, I use in my project, so I knew. And yes googling is indeed an important skill
B
@B-keen
Oct 13 2017 22:27
@sjames1958gm i know that is what the exercise says but i was looking to navigate JSON and try it another way looping through each element if found i.e. if the index id is 2548 prop is artist and artist is Bon Jovi (return collection[id][prop]; ) should equal Bon Jovi in the Free Code Camp window i'm getting the entire JSON but in chrome dev tools i'm getting Bon Jovi

var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};


// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

//var json = JSON.parse(collection);

  //var jkl = collection[id][prop].push(value);

  //var jkl = id;

  return collection[id][prop];
}

// Alter values below to test your code
//updateRecords(5439, "artist", "ABBA");
updateRecords(2548, "artist", "Bon Jovi");


"Bon Jovi"
Chrome
FCC
B
@B-keen
Oct 13 2017 22:32
  collection = {
 "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
},
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
}
Stephen James
@sjames1958gm
Oct 13 2017 22:35
@B-keen Looping is entirely unnecessary, they give you the keys to look up everything
@B-keen You need to test the incoming parameters first then change the collection
B
@B-keen
Oct 13 2017 22:46

@sjames1958gm ```
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

//var json = JSON.parse(collection);

//var jkl = collection[id][prop].push(value);

//var jkl = id;

if(prop === 'tracks' ){
collection[id][prop].push(value);

}
return collection;
}

// Alter values below to test your code
//updateRecords(5439, "artist", "ABBA");
updateRecords(1245, "tracks", "Addicted to Love");
//updateRecords(2548, "artist", "Bon Jovi");
```

var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};


// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

//var json = JSON.parse(collection);

  //var jkl = collection[id][prop].push(value);

  //var jkl = id;


  if(prop === 'tracks' ){
    collection[id][prop].push(value);


  }
  return collection;
}

// Alter values below to test your code
//updateRecords(5439, "artist", "ABBA");
updateRecords(1245, "tracks", "Addicted to Love");
//updateRecords(2548, "artist", "Bon Jovi");
Stephen James
@sjames1958gm
Oct 13 2017 22:47
@B-keen That is one case. But you should probably check the primary case of value != "" first
B
@B-keen
Oct 13 2017 22:52
@sjames1958gm i still have the question as to why is the behaviour different in the IDEs when i do a "return collection[id][prop] " i get just that element in chrome dev & node.js but when i do it in FCC it gives me the entire JSON
no problem i will do that Stephen
Stephen James
@sjames1958gm
Oct 13 2017 22:53
@B-keen Where are you seeing that it gives you the whole collection
B
@B-keen
Oct 13 2017 22:54

var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};


// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

//var json = JSON.parse(collection);

  //var jkl = collection[id][prop].push(value);

  //var jkl = id;

  return collection[id][prop];
}

// Alter values below to test your code
//updateRecords(5439, "artist", "ABBA");
updateRecords(2548, "artist", "Bon Jovi");


"Bon Jovi"
if you put that in Chrome or Node.js it gives you Bon Jovi
but when you run it in FCC it gives you the entire JSON
Spyrantis Theodoros
@thodorisanta
Oct 13 2017 23:17
lets say that i have a code that makes the user choose beetween the numbers 1 or 2 and accordingly to what he chose we add a class,either one or two accordinly to a paragraph p . how can i make an if statement that goes something like "if paragraph has the class one in it do that" else if "it has the class "two" in it do this?