Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/#basic-javascript

:open_mouth: :face_with_monocle: i will be so happy if I find this. I know ive been working on this one problem for too many days now lol

Asta la Vista babyyyyyyy

Ha ha Thanks Jeremy and ieahleen!!
but yea jeremy I picked up on what you were saying. the condition was not being ran because of the condition prior to it, if that makes sense. I am very happy I got pass this one, and I learn on this, thanks yall!

Nice work!

You can significantly simplify your code with this reordering, as a fun bonus

function updateRecords(records, id, prop, value) {
  if (value === "") {
    delete records[id][prop];
    return records;
  }
  if (prop !== "tracks") { // We already know value is not ""
    records[id][prop] = value;
    return records;
  }
  if (records[id].hasOwnProperty("tracks") === false) { // We already know prop is not "tracks"
    records[id][prop] = [value];
    return records;
  }
  if (records[id].hasOwnProperty("tracks") === true) { // We already know prop is not "tracks"
    records[id][prop].push(value);
    return records;
  }
}

More simplification along those lines is also possible :slight_smile: Generally, if you see repetition, it is an opportunity for simplification.

1 Like

and yes totally agree with simplifying whenever possible especially when you see repetition because that is a sign that code can be written more concise. I really appreciate the help! Cheers

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.