Record Collection vol1

Hello, I have some problems with finishing this lesson.

// 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 (records[id].prop !== "tracks" && records[id].prop?.value !== "") {
		return (records[id][prop] = value);
	if (records[id].prop === "tracks" && records[id].album.tracks === false) {
		return (records[id][prop] = [value]);
	if (records[id].prop === "tracks" && records[id].prop.value !== "") {
		return records[id][prop].push(value);
	if (records[id].prop.value === "") {
		return delete records[id][prop];
	return records;

Looks like, all is ok in the code (for me), but I can’t complete any tests

Are you sure this does what you think that it does? The return statement immediately stops the function and returns the value of the expression on the right.

I’ve edited your post 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 (').

Thanks for the tip. Going to refactor :}

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