settingsAccountsettings
Menusettings

Q: Display information about the musical track in JavaScript

+2 votes

Write a JavaScript program/function that displays information about the currently playing musical track.

The input comes as an array of string elements:

  • The first element is the name of the track
  • The second is the name of the artist performing and the third is the duration in minutes and seconds.

Examples:

Input:
['Number One', 'Nelly', '4:09']

Output:
Now Playing: Nelly – Number One [4:09]


The output should be printed to the console in the following format:
Now Playing: {artist name} - {track name} [{duration}]

asked in JavaScript category by user Jolie Ann

1 Answer

+1 vote

The js code:

function nowPlaying(input) {
    let artistName = input[1];
    let trackName = input[0];
    let duration = input[2];

    console.log("Now Playing: " + artistName + " - " + trackName + " [" + duration + "]");
}

nowPlaying(['Number One', 'Nelly', '4:09']);

 

answered by user paulcabalit
...