Question: JAVA 1. Create a function called padString(data, maxLength, padCharacter, padLeft) that returns data padded with padCharacter , either to the left (before data ) or
JAVA
1. Create a function called padString(data, maxLength, padCharacter, padLeft) that returns data padded with padCharacter, either to the left (before data) or the right (after data) based on padLeft, up to maxLength. The function must be saved in a file called catalog.js.
- data: Data to be padded, consider using String() to assist in performing length calculations if data is not a string
- maxLength: The numerical maximum length of padding and data combined, and no padding if the length of the data equals maxLength
- padCharacter: The string padding character (e.g. space)
- padLeft: Boolean true or false, where true means pad to the left of data, and false means pad to the right of data
2.
Create an array of song objects using the object literal syntax. Your array must have five songs. You can use any music billboard/chart that lists top songs to find the required information. Eventually, this array of song objects will be used to populate your song catalog. Each song object must have the following properties:
- title: song title
- artist: artist
- position: numerical order on the chart
- weeksOnChart: number of weeks on the chart
Below is an example of one of the objects. Remember, you must create five objects, and assign them to an array. The array should be declared using const. Use the variable name songs for the array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
