Tried recursion in Record Collection challenge, code doesn't check

Hi all, thing is I used recursion more than once, I don’t know whether that is allowed. The code doesn’t check. What am I doing wrong?
Here it is:

// Setup
var recordCollection = {
  2548: {
    albumTitle: 'Slippery When Wet',
    artist: 'Bon Jovi',
    tracks: ['Let It Rock', 'You Give Love a Bad Name']
  2468: {
    albumTitle: '1999',
    artist: 'Prince',
    tracks: ['1999', 'Little Red Corvette']
  1245: {
    artist: 'Robert Palmer',
    tracks: []
  5439: {
    albumTitle: 'ABBA Gold'

// Only change code below this line
function updateRecords(records, id, prop, value) {
if (value === "") {
  delete id[prop];
} else {
  var tracks = arr;
if (updateRecords(records, id[prop] === id[prop][tracks] && !id[prop].hasOwnProperty(tracks))) {
  return [];
if (updateRecords(records, id[prop] !== id[prop][tracks] && value !== "")) {
    return id[prop] = value;
} if (updateRecords(records, id[prop] === id[prop][tracks] && value !== "")) {

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

Thank you.

How, big picture, do you see recursion helping here? What is your base case? How do you ‘reduce’ the problem for the recursive call?

I haven’t seen a way to use recursion for this challenge.

1 Like

@JeremyLT You mean recursion here has no use? My base case is value equals none so it gets deleted. Maybe I chose a bad challenge for recursion. Can you guide me to do a challenge where it makes sense?

I see no way in which recursion helps.

You should always use the base case. How can you describe the other requirements in terms of deleting something?

1 Like

@JeremyLT Oh I get it. I chose a bad base case because there is no logical relation with the rest of cases. Is that OK? Is it still possible to use recursion here if I choose a good base case?

Can you explain how you see a base case and recursion helping? I really see no way to use recursion.

1 Like

@JeremyLT Ah you’re right. Recursion is not helping here. I’m sorry I’m so slow sometimes. I’m gonna look for other challenges where recursion can be helpful. Thanks. I think I’ve learned something here.

Looking for a different way to do a problem isn’t slow. That is showing you have creativity and are always looking for different angles on a problem.

Recursion can help in some cases. Non-linear search algorithms (binary search) can be done with recursion. Permutations can also be generated with recursion.

1 Like

@michaelnicol Thank you pal. I hope your faith in me somehow pays! I’m gonna look for those. Good night.

1 Like

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