Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
John Nunns
@johnnunns
ok, I think i see what you're saying, no need to write the actual specific id, because it will be found through testing. Let me see if I can apply it
Ken Haduch
@khaduch

@johnnunns - one example of one of these tests - the first one:

updateRecords(5439, "artist", "ABBA");

Your function will be called - the function arguments will be:

  • id = 5439
  • prop = "artist"
  • value = "ABBA"

The test says that after the function runs:

artist should be "ABBA"

So the testing code is going to read the collection object that is returned. Before your function runs, that record doesn't have an artist field. But you will add it, and since it is not a tracks property, no need to worry about array-type structures, you can just set that property using the variables and bracket notation - collection[id][prop] = value; That's a hint...
It is equivalent to having the code collection["5439"].artist = "ABBA"; but it is reusable because it is parameterized with the function arguments that will assume the values for the current function invocation.

John Nunns
@johnnunns
ok I hit the wall again. Tell me this. And I'm sorry I'm sure you've already answered but there's a disconnect somewhere for me. So if you have collection[id].hasOwnValue <-the else if statement will apply to multiple ids and then won't I be pushing the same song or artist to multiple ids? It seems if I don't specifically say the id number, I can't stop the push from going to multiple spots.
Zaurbek Zhakupov
@zzhakupov
Hello guys can I have some feedback on my conway's game of life project http://codepen.io/Zooll/pen/XNoRNY
John Nunns
@johnnunns
@khaduch
man coding is a humbling experience for my perceived intelligence :))
Andrew Thompson
@zovaaa
Where's the best place for some help with the wikipedia project? I can't for the life of me work out how to get the correct snippet for the results (i.e., search 't' and check the snippets) codepen: http://codepen.io/zovaaa/pen/eBMMxX
currently using this link: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=${query.value}&format=json&origin=*
Tom
@moT01
@johnnunns think of whats there, ...if you put if (collection[id].hasOwnProperty('someproperty');
Ken Haduch
@khaduch
@johnnunns - it is .hasOwnProperty(), I think that's what you meant? And the point is that you want to be able to work on multiple records. The thing is, that the function is only called with one value at a time - so for each invocation of the function, you'll probably be using different values, but ONLY ONE AT A TIME! That's the beauty of it! You can, of course, have something that would take action on all of the records in the collection, say, if you wanted to add another field - but you'd have to be getting multiple pieces of data in an array or something - so calm yourself. :) It will work, I promise!
Tom
@moT01
youre asking if the collection with that id has that property
it will only be that one id, because that variable is a single id
@zovaaa is that how you put a variable in a string?
ive always used the " + variable + ".com" style
but maybe your way works
Andrew Thompson
@zovaaa
Yeah, if you use backticks you can make it so `${variable}.com`
= variable + '.com'
Tom
@moT01
yea, figured that
John Nunns
@johnnunns

```
function updateRecords(id, prop, value) {
if(collection[id].tracks.hasOwnProperty(value)){
return collection;
}else {
collection[id].tracks.push("Addicted to Love");
}
if(collection[id].hasOwnProperty(prop)) {
return collection;
}else {
collection[id].push("tracks","artists");
}

}

``` @khaduch @moT01

function updateRecords(id, prop, value) {
  if(collection[id].tracks.hasOwnProperty(value)){
    return collection;
  }else {
    collection[id].tracks.push("Addicted to Love");
  }
  if(collection[id].hasOwnProperty(prop)) {
    return collection;
  }else {
    collection[id].push("tracks","artists");
  }






}
Tom
@moT01
@zovaaa the url gives results
but not the results you want?
@johnnunns if collection['1245'].tracks.hasOwnProperty("artist")
John Nunns
@johnnunns
function updateRecords(id, prop, value) {
  if(collection[id].tracks.hasOwnProperty(value)){
    return collection;
  }else {
    collection[id].tracks.push(value);
  }
  if(collection[id].hasOwnProperty(prop)) {
    return collection;
  }else {
    collection[id].push("tracks","artists");
  }
replaced the specific song with 'value'
Tom
@moT01
how can tracks have the property of artist
John Nunns
@johnnunns
well would it be collection[id].hasOwnProperty("tracks") then?
Andrew Thompson
@zovaaa
Yes, mine give incorrect description snippets when compared to the example
Tom
@moT01
@Zooll8 im not sure what's supposed to be happening, but it seems to get stuck after a while
what is incorrect? @zovaaa its giving me a description
i would probly just go with that
but if youre looking for something else, ...it might be the list=search
yea, i played around with that for a while, ...if youre interested
http://codepen.io/moT01/pen/LRoxrQ?editors=1010
here's what i came up with
Ken Haduch
@khaduch

@johnnunns - there are a few problems here.

  • you should be testing for value === '' or value !== '' somewhere in your code to be able to handle that situation, as described in the problem description
  • collection[id].tracks.hasOwnProperty(value) - this is not correct. tracks does not contain an object as its value, so it cannot be used with .hasOwnProperty() in the way you have it coded. (You would most likely get an error in the console if you looked at it when this code was attempted to be run.)
  • collection[id].tracks.push("Addicted to Love"); would work - if prop === "tracks" (you were supposed to be operating on the "tracks" property) and if value === "Addicted to Love" - In other words, you have hard-coded something that should be using the function arguments.
  • if(collection[id].hasOwnProperty(prop)) { - this test is not useful here. The function should always return collection; after it updates the record.
  • collection[id].push("tracks","artists"); - this is also not useful here - there is no condition here where you should be pushing the words "tracks" and "artists" into an object (which probably will fail anyway, since it collection[id] is not an array...

You have some of the concepts going in the right direction, but things are quite jumbled and confused, but let's try another approach. Look at the conditions that they want you to check - one of the biggies is value === "" or value !== "". If the value is blank, you are just supposed to delete the property that is given in the variable prop, at the ID that is given in the variable id. You have to use the delete function. You can write this code like this:

if ( value === '' ) {
    delete collection[id][prop]; // because the value is blank, just delete this
} else {
    // the value is not blank - there are other things to consider, most specifically, if `prop === "tracks"`
    if (prop === "tracks" ) {
        // do the things here to properly handle the "tracks" property
    } else {
        // the prop variable is not "tracks", just add the prop and value to the given record.
    }
}
return collection; // this is always done at the end of the function

that is what you should have as a basic idea for your function - you need to fill in the details. Look at the description of the problem, with this framework in mind, and see if you can get some of the tests to pass.

Tom
@moT01
@khaduch wow
Ken Haduch
@khaduch
@johnnunns @moT01 - I hate to be a party pooper, but I have to sign off for tonight. That's why I put so much detail & hints into my previous comment... 5 minutes for any followup?
Tom
@moT01
that's like a whole novel
John Nunns
@johnnunns
huge thanks for your patience. Both @khaduch and @moT01 . I'll give it a shot. And thanks for going into that much detail for me. Means a ton
CamperBot
@camperbot
johnnunns sends brownie points to @khaduch and @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @mot01 |http://www.freecodecamp.com/mot01
:star2: 2181 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
@johnnunns - as I said - this is a big stepping stone in writing a function that does something a little more complex than the problems up until this point. It's not good to just have the answer given to you, but it's not good to get too frustrated. I hope that helps. You can always find hints in the wiki, if you get too bogged down, but people here will help you, it's better to try and make it through and learn as much as you can. Step, step, step... good luck!
khaduch @khaduch - going offline for the night... going once... going twice... gone! Good night all - happy coding!
Josh
@joshfilippi
Can anyone help me get bootstrap working? I've just finished all the functionality of my local weather project and now i can't get button in the right place
There is a button under the temperature. I want it to be beside it
Bootstrap is loaded on the pen, everything is nested in a container-fluid element. but when i nest 2 elements in a 'row' class element, they dont appear in a row
Tom
@moT01

adding...

#temp {
  display: inline;
}

gets it close

@joshfilippi
livonian-router
@livonian-router
@joshfilippi and round your temp result
Josh
@joshfilippi
@moT01 thanks. it's a little better. I'd love to know why bootstrap grid isnt working
CamperBot
@camperbot
joshfilippi sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles: