Record Collectoin

I am not sure what I am missing on this challenge. It states I am not passing 3 test, but when I run it in my web console, the 1st 2 display the expected results…only the 3rd line is not correct.

Here is the failing test results:

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.

Here is my code:

function updateRecords(id, prop, value) {
                //if value is empty
                if(value === "") {
                    // delete property
                    delete collection[id][prop];
                }
                // If prop is "tracks" 
                else if (collection[id][prop] === "tracks") {
                    //the album have a "tracks" property
                    if(collection[id].hasOwnProperty("tracks")) {
                        // push the value onto the end of the album's existing tracks array
                        collection[id][tracks].push(value)
                    }
                    else {
                        //create an empty array 
                        collection[i][tracks] = [];
                        //before adding the new value to the album's corresponding property
                        collection[i][tracks].push(value);
                    }
                }
                else {
                        //update or set property of album
                        collection[id][prop] = value;
                    }
                return collection;
            }

            // Alter values below to test your code
            console.log(updateRecords(5439,"tracks","Take a Chance on Me"));
            console.log(updateRecords(1245,"tracks","Addicted to Love"));
            console.log(updateRecords(2468,"tracks","Free"));

Any help is greatly appreciated. Thank you.

is this how you check the value of the prop variable?

Hints
1 Take a look at what @ieahleen said are you sure that part of code is in the right position?
2 retake a look at https://www.w3schools.com/js/js_comparisons.asp is there something else you could use
3 you can use

collection[id][prop] 

at least 3 times

I was not thinking at all…made so many iterations, lost myself. I have it working now. It may not be pretty, but it works. Thank you for getting me on track…

function updateRecords(id, prop, value) {

                //If value is empty
                if(value === "") {
                    // delete the given prop property from the album
                    delete collection[id][prop];
                }

                // If prop isn't "tracks" and value isn't empty ("")
                if (prop !== "tracks" && value !== "") {
                    //update or set property of album
                    collection[id][prop] = value;
                }

                // If prop is "tracks" but the album doesn't have a "tracks" property
                if (prop === "tracks" && collection[id].hasOwnProperty("tracks") == false) {
                    //create an empty array 
                    collection[id].tracks = [];
                    //before adding the new value to the album's corresponding property
                    collection[id].tracks.push(value);
                }
                // If prop is "tracks"
                if (prop === "tracks") {
                    // and value isn't empty ("")
                    if (value !== ""){
                        // push the value onto the end of the album's existing tracks array
                        collection[id].tracks.push(value)
                    }
                    else {
                        // delete the given prop property from the album
                        delete collection[id][prop];
                    }
                    
                }

                return collection;
            }

you were doing well, your issue was really just that line and a few more syntax errors, the logic was sound

there were just some little small details to fix

anyway, now it works, congratulations! happy coding!