fix(curriculum) - clearer RecordCollection instructions (#49745)

* fix - clearer RecordCollection instructions

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/record-collection.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

---------

Co-authored-by: Muhammed Mustafa <muhammed@freecodecamp.org>
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
Jeremy L Thompson
2023-03-27 11:23:02 -06:00
committed by GitHub
parent 1d1174d4dd
commit e85510835c

View File

@@ -8,17 +8,24 @@ dashedName: record-collection
# --description--
You are given an object literal representing a part of your musical album collection. Each album has a unique id number as its key and several other properties. Not all albums have complete information.
You are creating a function that aids in the maintenance of a musical album collection. The collection is organized as an object that contains multiple albums which are also objects. Each album is represented in the collection with a unique `id` as the property name. Within each album object, there are various properties describing information about the album. Not all albums have complete information.
You start with an `updateRecords` function that takes an object literal, `records`, containing the musical album collection, an `id`, a `prop` (like `artist` or `tracks`), and a `value`. Complete the function using the rules below to modify the object passed to the function.
The `updateRecords` function takes 4 arguments represented by the following function parameters:
- Your function must always return the entire record collection object.
- If `prop` isn't `tracks` and `value` isn't an empty string, update or set that album's `prop` to `value`.
- If `prop` is `tracks` but the album doesn't have a `tracks` property, create an empty array and add `value` to it.
- If `prop` is `tracks` and `value` isn't an empty string, add `value` to the end of the album's existing `tracks` array.
- `records` - an object containing several individual albums
- `id` - a number representing a specific album in the `records` object
- `prop` - a string representing the name of the albums property to update
- `value` - a string containing the information used to update the albums property
Complete the function using the rules below to modify the object passed to the function.
- Your function must always return the entire `records` object.
- If `value` is an empty string, delete the given `prop` property from the album.
- If `prop` isnt `"tracks"` and `value` isn't an empty string, assign the `value` to that albums `prop`.
- If `prop` is `"tracks"` and `value` isnt an empty string, add the `value` to the end of the albums existing `"tracks"` array.
- If the album doesnt have a `"tracks"` property, create a new array for the album's `"tracks"` property before adding the `value` to it.
**Note:** A copy of the `recordCollection` object is used for the tests.
**Note:** A copy of the `recordCollection` object is used for the tests. You should not directly modify the `recordCollection` object.
# --hints--