Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.






                // Log the solution object value in a human-readable format

// Assign your solution text to obj
var obj = { "index.js": "// Setup\nvar collection = {\n    \"2548\": {\n      \"album\": \"Slippery When Wet\",\n      \"artist\": \"Bon Jovi\",\n      \"tracks\": [ \n        \"Let It Rock\", \n        \"You Give Love a Bad Name\" \n      ]\n    },\n    \"2468\": {\n      \"album\": \"1999\",\n      \"artist\": \"Prince\",\n      \"tracks\": [ \n        \"1999\", \n        \"Little Red Corvette\" \n      ]\n    },\n    \"1245\": {\n      \"artist\": \"Robert Palmer\",\n      \"tracks\": [ ]\n    },\n    \"5439\": {\n      \"album\": \"ABBA Gold\"\n    }\n};\n// Keep a copy of the collection for tests\nvar collectionCopy = JSON.parse(JSON.stringify(collection));\n\n// Only change code below this line\nfunction updateRecords(id, prop, value) {\n  if (prop === 'artist' && value !== '') {\n    collection[id].artist = value;\n  } else if (prop === 'artist' && value === '') {\n    delete collection[id][prop];\n  };\n  \n  if (prop === 'tracks' && value !== '') {\n    if (!collection[id].tracks) {\n      collection[id].tracks = [];\n    }\n    collection[id].tracks.push(value);\n  } else if (prop === 'tracks' && value === '') {\n    delete collection[id][prop];\n  }\n  \n  if (prop === 'album') {\n    collection[id].album = value;\n  }\n  return collection;\n}\n\n// Alter values below to test your code\nupdateRecords(5439, \"artist\", \"ABBA\");\n"

// Object.keys() returns an array whose elements are strings corresponding to the enumerable properties found directly upon object.  

// A simpler method than above, since we know each file's object key:
// console.log(obj["index.js"]);

/* References: