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
CamperBot
@camperbot
:star2: 2178 | @khaduch |http://www.freecodecamp.com/khaduch
Tom
@moT01
yea, can you be more specific at all? have any code to show?
Ken Haduch
@khaduch
@johnnunns - please post your code. It's not really too difficult once you get going in the right direction.
John Nunns
@johnnunns
function updateRecords(id, prop, value) {
  if(collection.tracks.hasOwnProperty()){
    return collection;
  }else if (collection.tracks.hasOwnProperty === false){
    collection.tracks.push
  }
It's very unfinished, I'm not sure if I'm headed in the right direction
Ken Haduch
@khaduch
@johnnunns - one question - does collection have a tracks property, ever? What kind of properties does collection have - the "first level" of properties. For that matter, what kind of structure is collection?
John Nunns
@johnnunns
I guess what you're telling me is that the tracks property belongs to the id which is the record number. correct?
so if I were going to push, it'd have to be collections.2548.tracks.push()
Ken Haduch
@khaduch
probably that's what I'm telling you, so if you have a collection, and an id, what would you do with that to try and find a tracks property? Your answer is close, but you have to make sure that you understand when you can use dot notation vs. bracket notation to access an object.
John Nunns
@johnnunns
alright. lets rework. Thanks @khaduch. mini lightbulb
CamperBot
@camperbot
johnnunns sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2179 | @khaduch |http://www.freecodecamp.com/khaduch
Tom
@moT01
say @khaduch, how my clock look?
http://codepen.io/moT01/pen/PbrzQo
John Nunns
@johnnunns
@khaduch
function updateRecords(id, prop, value) {
  if(collection["1245"].tracks.hasOwnProperty()){
    return collection;
  }else {
    collection['1245'].tracks.push("Don't know")
  }
Tom
@moT01
@johnnunns use the parameters, they will be different each time
Ken Haduch
@khaduch
@johnnunns - okay, that might work, but remember that you are getting different id values, and those values will be the numbers, so you should be able to use that variable in your data access.
Tom
@moT01
@johnnunns check out the syntax on the .hasownprop method
should be a link on that exercises page
John Nunns
@johnnunns
function updateRecords(id, prop, value) {
  if(collection["1245"].tracks.hasOwnProperty(prop)){
    return collection;
  }else {
    collection['1245'].tracks.push("Don't know");
  }
better?
Tom
@moT01
check out kens last message
1245 won't be 1245 every time
John Nunns
@johnnunns
why won't it always be 1245?? @moT01
Ken Haduch
@khaduch
@johnnunns - first things first - you HAVE TO USE THE id - there is no way to make it work otherwise! Check the test cases that will be run to validate your solution.
Tom
@moT01
if you hit the runtests button, you will see the different tests you need to pass
Ken Haduch
@khaduch
@moT01 - Pomodoro... Why did you decide to wrap from 1 to 99 when decrementing the session count? And break count. I don't think it's a bad idea, just a surprise.
John Nunns
@johnnunns
I know I have different tests, I just want to make sure I'm on the right track before I start the others. @moT01 @khaduch am I not using the id when i write 1245?
Tom
@moT01
no, @johnnunns you need to use the parameter sent to the function
youre using AN id, but not always the right one
Ken Haduch
@khaduch
@johnnunns - you are using an ID value that is in the data, that might be true, but you should just use the variable id because when you call the function, as they have one sample call at the bottom of the edit window, that value will be avaiable in the id variable and you'll be using it in the way that will be a general-purpose solution. But, for the sake of argument, you are using one of the values. So let's move on to the next thing. If you have this construct: collection["1245"] - what does that allow you to access within the data?
Tom
@moT01
im not sure why i went that way, @khaduch
i suppose i coulda went to 59
@khaduch originally i was going to have seconds and hours, and made some html and js that i knew for it, ...but when it came to the interval (only thing i couldn't do) i was trying to do too much, too fast, so i had to simplify
it was 59 right away for the seconds, and when i deleted the seconds i changed it to 99 for some reason
John Nunns
@johnnunns
only the "1245" id @khaduch
Ken Haduch
@khaduch

@moT01 - well, it's better than counting into the negative values, I've seen that. So the next question is that I didn't hear any sound when it changed from the session to the break? I think that is one of the requirements, they mention it in the user stories, I think?
One other thing, and if you have it working, it's fine - it's easier to keep your time value in seconds only, and not have to make calculations against seconds and minutes.

But it looks good overall!

@johnnunns - right - but that's not what I'm after. If you have that collection["1245"], how would you determine whether or not it has a tracks property?
Tom
@moT01
@johnnunns correct, you need to get and whatever id is sent to the function
get at*
John Nunns
@johnnunns
by adding the .hasOwnProperty
@khaduch
Tom
@moT01
know of a good place where there's some audio files i can use?
Ken Haduch
@khaduch
@johnnunns - ookay - so in your code, you have this: collection["1245"].tracks.hasOwnProperty(prop) - what is that going to tell you? Is it correct? (I would say that tracks might be there, it might not be there, and if it is there, it needs to be an array, as many of the records are initialized with an array.) But does an array have properties?
@moT01 - I've heard some really strange audio files being played on some of these timers! I don't know the best place to find them - google "free audio files" or something like that.
John Nunns
@johnnunns
Well in the problem, 1245 already has the tracks property, but no value @khaduch
i can see where the other one, 5439, would need to be asked if it has the property in the first place

// Setup
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) {
  if(collection[1245].tracks.hasOwnProperty(value)){
    return collection;
  }else {
    collection[1245].tracks.push("Addicted to Love");
  }
  if(collection[5439].hasOwnProperty(prop)) {
    return collection;
  }else if(collection[5439])
  }
Tom
@moT01
oh boy
Ken Haduch
@khaduch
@johnnunns - hmmm - it looks like they changed the data ffrom the last time I looked at it. I don't remember that they had one with an empty array. Okay...
John Nunns
@johnnunns
sorry I didn't just repost in the first place @khaduch
Tom
@moT01
@johnnunns hint: there shouldn't be any testing of the actual id numbers