Music List


10 points



This app maintains a list of the user's top 10 favorite songs.

There are at least 2 ways to write this app. For the first approach, add 10 Labels to a screen. These Labels will store the names of songs. Add a box where the user can enter a song title. Add a dropdown box with options from 1 to 10. Add a button. When the button is clicked, the app displays the song title in the chosen slot of the 10 available. It will be possible to overwrite a previous choice with a new choice. You will probably use IF statements in order to correctly position each song title on the screen.



Second approach: This approach uses a list to store the names of the songs. You can declare a list like this:

var list = [];

You can access the 3rd element in the list in this way: list[3]. (Note that list[0] is actually the first element in the list. You don't have to start at 0, however; you can start at 1, which is what I did for this program.)

You insert an element into the list like this: list[4] = song;

There are other list functions that you probably won't need here. 'appendItem()' adds an item to the end of the list. 'insertItem()' adds an item to the list. 'removeItem()' removes an item from the list.

When a user enters a new song, indicating which position it should occupy in the list and clicks the button, an onEvent() runs. The app enters the new song at that position in the list.

I wrote a function setUpList() that stores an empty string (" ") in each of the 10 positions of the list. You can write a FOR loop for this. This function is called once when the user first clicks the button.

I wrote a second function displaySongs() that displays the 10 songs in the Text Area. This function uses a FOR loop to transfer the contents of the list into 1 string that is then displayed. The "\n" is a linefeed character that is used to move the output to the next line. This function is called in the onEvent() that runs when the button is clicked.




The video shows what a completed app should do.