Basic JavaScript - Record Collection

please give me a detailed explanation as to what i am doing wrong. i am extremely confused both with the problem and how its written.
Tell us what’s happening:
Describe your issue in detail here.

Your code so far

// Setup
const 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) {
  return records;
 if(value===""){
   delete records[id][prop];//If value is an empty string, delete the given prop property from the album.
 }
 if(prop!=="tracks"&&value!==""){
   record[id][value]=[prop];
 }//If prop isn't tracks and value isn't an empty string, assign the value to that album's prop.
If(prop==="tracks"&&value!==""&& "album"==="tracks"==="");{
  
    records[id][prop]= [];
   [value]= push[value]; 
}
  }

 //If prop is tracks and value isn't an empty string, you need to update the album's tracks array. First, if the album does not have a tracks property, assign it an empty array. Then add the value as the last item in the album's tracks array.
   
 
 

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

A return statement immediately stops a function

what else because now record is undefined

Record is undefined. It’s not a variable in your code anywhere. Check your spelling

records* same issue.

When you fix your typo it still says record is undefined? That means you didn’t fix your typo.

const 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 records[id][prop];//If value is an empty string, delete the given prop property from the album.
 }
 if(prop!=="tracks"&&value!==""){
   record[id][value]=[prop];
 }//If prop isn't tracks and value isn't an empty string, assign the value to that album's prop.
If(prop==="tracks"&&value!==""&& "album"==="tracks"==="");{
  
    records[id][prop]= [];
   [value]= push[value]; 
}
return records;
  }

//If prop is tracks and value isn’t an empty string, you need to update the album’s tracks array. First, if the album does not have a tracks property, assign it an empty array. Then add the value as the last item in the album’s tracks array.

updateRecords(recordCollection, 5439, ‘artist’, ‘ABBA’);

  • Failed: After updateRecords(recordCollection, 1245, "tracks", "Addicted to Love"), tracks should have the string Addicted to Love as the last element.

  • Failed: After updateRecords(recordCollection, 2468, "tracks", "Free"), tracks should have the string 1999 as the first element.

  • Failed: After updateRecords(recordCollection, 2548, "tracks", ""), tracks should not be set

  • Failed: After updateRecords(recordCollection, 1245, "albumTitle", "Riptide"), albumTitle should be the string Riptide

27

26

23

24

25

22

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

// running tests After

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

,

artist

should be the string

ABBA

After

updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me")

,

tracks

should have the string

Take a Chance on Me

as the last and only element. After

updateRecords(recordCollection, 2548, "artist", "")

,

artist

should not be set After

updateRecords(recordCollection, 1245, "tracks", "Addicted to Love")

,

tracks

should have the string

Addicted to Love

as the last element. After

updateRecords(recordCollection, 2468, "tracks", "Free")

,

tracks

should have the string

1999

as the first element. After

updateRecords(recordCollection, 2548, "tracks", "")

,

tracks

should not be set After

updateRecords(recordCollection, 1245, "albumTitle", "Riptide")

,

albumTitle

should be the string

Riptide

// tests completed // console output ReferenceError: record is not defined

Yes, you did not fix your typo

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

i found the typo, and that didnt fix the issue

The typo is still in your code here. You fixed this?

yes and i still get the same errors

If you still get an error saying ReferenceError: record is not defined, then you did not fix the typo

ok look stop trolling me i fixed the "records " problem it says my if statement is not defined. ive been at this for 2 days a total 12 hours please if youre going to give me a reply, actually look and read my code and fix it or dont answer and have someone who will take over.

I’m not trolling you. You said

If your errors are the exact same, then you still have record instead of records. If the errors are not the exact same, then please show your updated code.

// Setup
const 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 records[id][prop];//If value is an empty string, delete the given prop property from the album.
 }
 if(prop!=="tracks"&&value!==""){
   records[id][value]=[prop];
 }//If prop isn't tracks and value isn't an empty string, assign the value to that album's prop.
if(prop==="tracks"&&value!==""&& "album"==="tracks"===""){
  records[id][prop]= [];
   [value]= push[value]; 
}
return records;
  }

 //If prop is tracks and value isn't an empty string, you need to update the album's tracks array. First, if the album does not have a tracks property, assign it an empty array. Then add the value as the last item in the album's tracks array.
   
 
 

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

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I’m going to apply some conventional formatting to your code so its easier to read

function updateRecords(records, id, prop, value) {
 if (value === "") {
   // If value is an empty string, delete the given prop property from the album.
   delete records[id][prop];
 }
 if (prop !== "tracks" && value !== "") {
   // If prop isn't tracks and value isn't an empty string, assign the value to that album's prop.
   records[id][value] = [prop];
 }
 if (prop === "tracks" && value !=="" && "album" === "tracks" === "") {
   records[id][prop] = [];
   [value] = push[value]; 
  }
  return records;
}

Now, first question. Why this line:

Second question:

What does this condition mean?

Third question:

What are these lines doing?

  1. assign the value to the album’s prop im not sure how to do that properly
  2. if prop equals tracks and value equals blank string and album equals tracks and tracks equals blank string
  3. assigning empty array to property if it meets the requirements of if statement and giving value a value.
  • please explain how this is suppose to be written because i am having trouble grasping combing the concepts as the course continues.

The issue here is that you 're putting the value into an array. But the only property that uses arrays in ‘tracks’

This is where you have a problem. Two different strings can never equal each other, so this can’t be a condition that works.

You should not always overwrite the tracks with an empty array.

What does that last bullet point say? We need to look at it sentence by sentence.