Question: JAVA (SUB PART OF OTHER QUESTION) https://www.chegg.com/homework-help/questions-and-answers/java-1-create-function-called-padstring-data-maxlength-padcharacter-padleft-returns-data-p-q68117540?trackid=hsj6_lPM Step 7. 111/p3/catalog.js: catalogObject custom object You will be creating a custom object called catalogObject that will server
JAVA (SUB PART OF OTHER QUESTION)
https://www.chegg.com/homework-help/questions-and-answers/java-1-create-function-called-padstring-data-maxlength-padcharacter-padleft-returns-data-p-q68117540?trackid=hsj6_lPM
Step 7. 111/p3/catalog.js: catalogObject custom object You will be creating a custom object called catalogObject that will server as a container for all of the song catalog functionality. This object will include catalog properties and methods. We will incrementally add and test functionality. Initially, we'll declare the catalogObject, declare an array property _songs initialized to an empty array, add method addSong(props) to add a song to _songs, and method listSongs() to list all of the songs in _songs:
- _songs: empty array property
- addSong(props): Add a song to _songs, where method parameter props, short for properties, is a song object. The addSong() method must use the String trim() (Links to an external site.) method to ensure the song title has no leading or trailing white space.
- listSongs(): Iterates through _songs array and lists out the songs. You must use a template literal (Links to an external site.) to output the songs to the Console. Template literals make formatting multi-variable output easier.
console.log(`${position} - ${title}, ${artist} (${weeks})`); Use the following steps to test catalogObject custom object
- Create an instance of catalogObject:
const catalog = Object.create(catalogObject);
- Load the catalog of songs by creating a for loop that iterates through the songs array, calling catalog.addSong() for each song in the songs array.
- Call catalog.listSongs() to list each song in the songs array
- Test your code changes by using the browser refresh button to reload catalog.html
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
