Basic JavaScript - Record Collection

Tell us what’s happening:
Hi all. sorry for my English. why doesn’t the test pass? I manually enter test lines through console.log() and see in the console that everything is working. Maybe I don’t understand the terms of the problem?
всем привет. почему не проходит тест? я вручную через console.log() ввожу тестовые строки и в консоли вижу, что всё работает. Может я не так понимаю условия задачи?

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) {

 if (value == false) {
		delete recordCollection[id][prop];
		
	}

	else {

		if (prop != "tracks" && value != false) {
			recordCollection[id][prop] = value;
			
		}
		else {
			if (prop === "tracks" && value != false) {
				if (recordCollection[id][prop]) {
					recordCollection[id][prop].push(value);
					
				}
				else {
					recordCollection[id][prop] = [value];
				
				}
			}
		}

	}

 return records;
}

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

//console.log(updateRecords(recordCollection, 1245, "albumTitle", "Riptide"));

//console.log(recordCollection);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 OPR/97.0.0.0

Challenge: Basic JavaScript - Record Collection

Link to the challenge:

You are using recordCollection instead of records

I would not make this comparison like this. The value is a string, not a boolean

1 Like

How can I check if a string is empty? I reasoned like this: if the string is empty, then it is a boolean zero (false). Or is it better to do a comparison on the length of the string “value.length = 0”?

You can check if the string is literally an empty string:

myString === ""