Syntax errors on records collections

Tell us what’s happening:
Describe your issue in detail here.only geting syntax errors when writing out code i try meny examples to but same result

   **Your code so far**

// 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 (prop !== 'tracks' && value !== ""){records[id][prop] = value;}



  




 return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

If I run your code, I see no syntax errors, but I do see several test failures

// 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 (prop !== 'tracks' && value !== "") {
    records[id][prop] = value;
  }
 return records;
}

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

**Tell us what’s happening:**only getting syntax errors when writing out code i try meny examples to but same result fustrated
Describe your issue in detail here.

   **Your code so far**

// 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 (prop !== 'tracks' && value !== ""){records[id][prop] = value;}else if(prop ==="tracks" && records[id]hasOwnProperty("tracks"))records[id][prop] =[value];}else if (prop === "tracks" && value !== "") {records[id][prop].push(value);
}else if(value ===""){delete records[id][prop];
}



  




 return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

I do see syntax errors on this version of your code. Correct formatting helps show the problem

// Only change code below this line
function updateRecords(records, id, prop, value) {
  if (prop !== 'tracks' && value !== ""){
    records[id][prop] = value;
// ---------- LOOK HERE ----------
  } else if (prop === "tracks" && records[id]hasOwnProperty("tracks")) // LOOK VERY CAREFULLY RIGHT HERE BECAUSE YOU ARE MISSING SOMETHING (TWO THINGS IN FACT)
// ---------- LOOK HERE ----------
    records[id][prop] = [value];
  } else if (prop === "tracks" && value !== "") {
    records[id][prop].push(value);
  } else if(value === "") {
    delete records[id][prop];
  }
 return records;
}

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

so whats the solution

I’m not going to fix your code for you.

Do you see the line I indicated above? There are two syntax problems on that line.

yea I deleted the line and now wondering what to replace it with

I don’t think you need to delete that line. You need to fix the two syntax problems on that line.

Can you describe what that line does?

well i thought you new i have been working on this promblem a hold 24 hours now and just dont see where is the problem

How can I possibly know what you think this line does?

Please, can you describe what that line does?

  • If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it.
  } else if (prop === "tracks" && records[id]hasOwnProperty("tracks")) // LOOK VERY CAREFULLY RIGHT HERE BECAUSE YOU ARE MISSING SOMETHING (TWO THINGS IN FACT)

I don’t see anywhere that an array is being created in this one line. That can’t possibly be what that one single line does.

There are two syntax bugs in this line. One of them comes from your second condition, which is why I am trying to get you to look at it and actually describe what it does. The second comes from basic if statement syntax.

I get the impression that you are trying to duplicate the solution you are looking at rather than understanding and creating a solution on your own. This sort of approach makes it very easy to write bugs and very hard to find and understand those bugs. I’m trying to get you to try to actually read and understand the code so that you can see where the problems are.

(There is also a logical bug, but its hard to find logical bugs when the code cannot run due to syntax bugs.)

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