Question: Language: JavaScript Working with this code: function padString(data, maxLength, padCharacter, padLeft) { while(data.length
Language: JavaScript
Working with this code:
function padString(data, maxLength, padCharacter, padLeft)
{
while(data.length { if(padLeft) { data=padCharacter+data; } else { data=data+padCharacter; } } return data; } const songs = [ { title: "Drivers License", artist: "Olivia Rodrigo", position: 1, weeksOnChart: 3, }, { title: "Mood", artist: "24kGoldn Featuring iann dior", position: 2, weeksOnChart: 25, }, { title: "Blinding Lights", artist: "The Weekend", position: 3, weeksOnChart: 60, }, { title: "34+35", artist: "Ariana Grande", position: 4, weeksOnChart: 13, }, { title: "Levitating", artist: "Dua Lipa Featuring DaBaby", position: 5, weeksOnChart: 17, } ] #7 let catalogObject = { _songs: [], addSongs: function(props) { props.title = props.title.trim() props.artists = props.artist.trim() this._songs.push(props); }, listSongs: function () { for (let i = 0; i < this._songs.length; i++) { let ratio = this._songs[i]; console.log(`${ratio.position} - ${ratio.title}, ${ratio.artist} (${ratio.weeksOnChart})`); } } } const catalog = Object.create(catalogObject); for (let i = 0; i < 5; i++) { catalog.addSongs(songs[i]); } catalog.listSongs(); ---------------------------- Question: Add padString() to catalogObject, and update addSong() and listSongs() to support padded output The output in the Console isn't very easy to read, so format the output so that each column is padded.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
