SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
Here is app.js, artist.js and songs.js file. Can you look at the my code and point any error in it. As
the assignment requirement, when the button is clicked, it show artist name, link and songs, but
mine only show name and link. I need to help in showing the song table.
/**
* artists.js
*
* The app's list of Artists
*/
window.artists = [
{
id: "a1",
name: "Ingrid Michaelson",
link: [
{
url: "https://www.instagram.com/ingridmichaelson/?hl=en",
name: "Instagram"
},
{
url: "https://twitter.com/ingridmusic",
name: "Twitter"
},
{
url: "https://open.spotify.com/artist/2vm8GdHyrJh2O2MfbQFYG0",
name: "Spotify"
}
]
},
{
id: "a2",
name: "Katie Melua",
link: [
{
url: "https://www.instagram.com/katiemeluaofficial/?hl=en",
name: "Instagram"
},
{
url: "https://twitter.com/katiemelua",
name: "Twitter"
},
{
url: "https://open.spotify.com/artist/5uCXJWo3WoXgqv3T1RlAbh",
name: "Spotify"
}
]
},
{
id: "a3",
name: "Birdy",
link: [
{
url: "https://www.instagram.com/birdyinstagram/?hl=en",
name: "Instagram"
},
{
url: "https://twitter.com/birdy?lang=en",
name: "Twitter"
},
{
url: "https://open.spotify.com/artist/2WX2uTcsvV5OnS0inACecP",
name: "Spotify"
}
]
}
];
/**
* songs.js
*
* The app's songs
*/
window.songs = [
{
id: "s1",
artistId: "a1",
title: "The Way I Am",
year: "2007",
duration: "135",
flagged: "false"
},
{
id: "s2",
artistId: "a1",
title: "You And I",
year: "2008",
duration: "148",
flagged: "false"
},
{
id: "s3",
artistId: "a1",
title: "Everybody",
year: "2009",
duration: "209",
flagged: "false"
},
{
id: "s4",
artistId: "a1",
title: "Girls Chase Boys",
year: "2014",
duration: "221",
flagged: "false"
},
{
id: "s5",
artistId: "a1",
title: "Afterlife",
year: "2014",
duration: "281",
flagged: "false"
},
{
id: "s6",
artistId: "a1",
title: "Time Machine",
year: "2019",
duration: "212",
flagged: "true"
},
{
id: "s7",
artistId: "a1",
title: "The Lotto",
year: "2020",
duration: "193",
flagged: "false"
},
{
id: "s8",
artistId: "a2",
title: "Nine Million Bicycles",
year: "2005",
duration: "195",
flagged: "false"
},
{
id: "s9",
artistId: "a2",
title: "Piece By Piece",
year: "2005",
duration: "204",
flagged: "false"
},
{
id: "s10",
artistId: "a2",
title: "Wonderful Life",
year: "2010",
duration: "244",
flagged: "false"
},
{
id: "s11",
artistId: "a2",
title: "All Over The World",
year: "2012",
duration: "176",
flagged: "false"
},
{
id: "s12",
artistId: "a2",
title: "Dreams On Fire",
year: "2016",
duration: "245",
flagged: "false"
},
{
id: "s13",
artistId: "a2",
title: "Joy",
year: "2020",
duration: "193",
flagged: "false"
},
{
id: "s14",
artistId: "a2",
title: "Quiet Moves",
year: "2023",
duration: "218",
flagged: "true"
},
{
id: "s15",
artistId: "a3",
title: "Skinny Love",
year: "2011",
duration: "203",
flagged: "false"
},
{
id: "s16",
artistId: "a3",
title: "People Help the People",
year: "20111",
duration: "256",
flagged: "false"
},
{
id: "s17",
artistId: "a3",
title: "Wings",
year: "2013",
duration: "252",
flagged: "false"
},
{
id: "s18",
artistId: "a3",
title: "All You Never Say",
year: "2013",
duration: "278",
flagged: "true"
},
{
id: "s19",
artistId: "a3",
title: "Keep Your Head Up",
year: "2016",
duration: "208",
flagged: "false"
},
{
id: "s20",
artistId: "a3",
title: "Beautiful Lies",
year: "2016",
duration: "170",
flagged: "true"
},
{
id: "s21",
artistId: "a3",
title: "Second Hand News",
year: "2021",
duration: "248",
flagged: "false"
},
{
id: "s22",
artistId: "a3",
title: "Young Heart",
year: "2021",
duration: "358",
flagged: "false"
}
];
// All of our data is available on the global `window` object.
// Create local variables to work with it in this file.
const { artists, songs } = window;
// Create a reference to the nav element of the menu
document.addEventListener(`DOMContentLoaded`, function () {
const menu = document.querySelector("#menu");
const songTable = document.querySelector("#songs");
// Loop through each artist in the artists array
for (let i = 0; i < artists.length; i++) {
const artist = artists[i];
const button = document.createElement("button");
button.textContent = artist.name;
button.onclick = function () {
updatedArtist(artist);
};
menu.appendChild(button);
}
// Get the current artist
function updatedArtist(artist) {
const artistName = document.getElementById("selected-artist");
artistName.textContent = artist.name;
artistName.innerHTML += artist.link
.map((link) => {
return ` ${link.name}`;
})
.join(",");
songTable.querySelector("tbody").innerHTML = "";
// Get all songs for the current artist
const artistSongs = songs.filter(function (s) {
return s.artists.includes(artist.id) && !s.flagged;
});
// Loop through each song in the song array
artistSongs.forEach(function (song) {
const row = document.createElement("tr");
row.addEventListener(`click`, function () {
console.log(song.title);
});
const colId = document.createElement("td");
colId.textContent = song.id;
row.appendChild(colId);
const colTitle = document.createElement("td");
colTitle.textContent = song.title;
row.appendChild(colTitle);
const colYear = document.createElement("td");
colYear.textContent = song.year;
row.appendChild(colYear);
const colDuration = document.createElement("td");
colDuration.textContent = formatDuration(song.duration);
songTable.querySelector("tbody").appendChild(row);
});
function formatDuration(totalSecond) {
var minutes = Math.floor(totalSecond / 60);
var seconds = totalSecond % 60;
if (seconds < 10) {
seconds = "0" + seconds;
}
return minutes + ":" + seconds;
}
}
});
// For debugging, display all of our data in the console. You can remove this later.
console.log({ artists, songs }, "App Data")
Overview This assignment is designed to have you practice working with HTML and the DOM
in order to create both static and dynamic web content. You are asked to prototype a fictional
Music App. Your app will focus on a specific music genre and allow users to browse different
artists and find specific songs. Because your app's artists and songs will change frequently, we
often separate our data from its UI representation. This allows us to quickly make changes and
have the app always use the most current music catalogue. NOTE: in a reaf music app, our data
would be stored in a database. We will simulate working with a database by using JavaScript
Objects and Arrays in separate files. Pick Your Music Genre and Artists, Songs You need to
decide on the following details for your app: - Music Genre: your music app is going to focus on
a particular type of music. What is it? You could use the same type of music as you chose in
Assignment 3 or pick another. - Name: what is your app called? Pick something unique and
relevant to your chosen music genre. - Slogan: what is your store's slogan (i.e., a short
description)? This will help a user to determine if your music app is worth using. - Artists: which
music artists/bands does your app include? Based on your chosen music genre, pick at least 3
artists that make this type of music. No two students can use the exact same set of artists. -
Songs: pick a minimum of 20 songs by your chosen artists. Each song will belong to one of the
artists.
Each song needs the following things: - id: a unique String that identifies this song. For example:
"s 1 " or "song-01" or "V1StGXR8". It doesn't matter what format you choose as long as each
song has its own, unique value. Also, make sure the artist id and song id are different. - artistld: a
String that indicates which artist this song belongs to - title: a short String that names the song -
year: a String with the year (4 digits) that the song was recorded - duration: a Number of seconds
(i.e., an Integer value) for the song's length. When we store time values, we often store them in
seconds vs. floats, and convert them to minutes, seconds in the UI for display. - flagged: a
Boolean that indicates whether this song has been flagged in the system, and should NOT be
shown to users. Make sure at least 2 of your songs have flagged set to true.
Your artist and song data will go in 'src/artists.js' and 'src/songs.js' respectively. See these files
for technical details about how to code your data. Take some time now to enter all of your app's
data. Store Web Site HTML Your app's HTML file is located in 'src/index.html'. A brief HTML
skeleton has been created, and you are asked to fill in the rest using your information above.
Some of your site will be static (i.e., coded in HTML directly in index.html) and never change.
Other parts of the site will be dynamic (i.e., created using DOM API calls at run-time) and will
update in response to various events and user actions. Here is a basic wireframe of what your site
needs to include, and which parts are static or dynamic. NOTE: don't worry too much about how
it looks. Focus on the structure and functionality. Artist1 Name (Twitter, Instagram,
SoundCloud)
1. Create an event handler to run when the page is loaded. Make sure you don't do anything to
the DOM until it's fully loaded. Your function should do the following: a. Create all of the
buttons for your store's Artists i. Loop through all of your Artist objects and create a< button >
element for each, adding it to the nav id = "menu" > ii. Use each Artist's name for the button's
text iii. When the button is clicked, show that Artists Name, Links, and Songs. See below for
more details. b. Show a list of Songs in the tbody > of your Table. By default, you should use
your first Artist on load. See below for more details 2. Write a function that will show a list of
songs in the < tbody rows from the tbody >. HINT: inner HTML =un c. Filter your Songs Array
(i.e., use Array.prototype.filter(j) to get: i. All Songs for the chosen Artist. HINT: use
Array.prototype.includes() ii. All Songs that are NOT flagged d. Loop (use
Array.prototype.forEach(h) over your filtered song list and add them to the table's body using
DOM methods (i.e., not innerHTML): i. Create atr> element 1. Add a click handler to your that
will console.log() the song whenever the user clicks it ii. Create elements for the song's name,
year, and duration. Convert the duration in seconds to a value in mintues:seconds iii. Append
these td> elements to the < tr > iv. Append this < tr > to the < tbody> In your solution, you will
likely require all of the following: - console. log() and NOTE that you can log Objects like so:
console.log({ object }) - document.querySelector(j) to find elements in the DOM -
document.createElement() to create new DOM elements - node.appendChild() to add an element
as a child of a DOM node - element.innerHTML to modify the HTML content of an element.
Don't overuse this!

Contenu connexe

Similaire à Here is app.js, artist.js and songs.js file. Can you look at the my .pdf

Last fm api_overview
Last fm api_overviewLast fm api_overview
Last fm api_overview
yuliang
 
Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdf
fazanmobiles
 
Attracted by the success of Spotify, a group of students wants to bu.pdf
Attracted by the success of Spotify, a group of students wants to bu.pdfAttracted by the success of Spotify, a group of students wants to bu.pdf
Attracted by the success of Spotify, a group of students wants to bu.pdf
rajafamous
 
You are to consider the design of a web app to help a night .pdf
You are to consider the design of a web app to help a night .pdfYou are to consider the design of a web app to help a night .pdf
You are to consider the design of a web app to help a night .pdf
shanth8
 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docx
jacksnathalie
 
3-4E Attracted by the success of Spotify- a group of students wants to.pdf
3-4E Attracted by the success of Spotify- a group of students wants to.pdf3-4E Attracted by the success of Spotify- a group of students wants to.pdf
3-4E Attracted by the success of Spotify- a group of students wants to.pdf
JoeltfNashq
 
Problem 2 struct to hold information about a song struct So.pdf
 Problem 2 struct to hold information about a song struct So.pdf Problem 2 struct to hold information about a song struct So.pdf
Problem 2 struct to hold information about a song struct So.pdf
ahujaelectronics175
 
Wp dev day_using_the_nokia_music_apis
Wp dev day_using_the_nokia_music_apisWp dev day_using_the_nokia_music_apis
Wp dev day_using_the_nokia_music_apis
Steve Robbins
 
Lesson 1 nea brief annotations
Lesson 1   nea brief annotationsLesson 1   nea brief annotations
Lesson 1 nea brief annotations
belleaj
 

Similaire à Here is app.js, artist.js and songs.js file. Can you look at the my .pdf (20)

Last fm api_overview
Last fm api_overviewLast fm api_overview
Last fm api_overview
 
Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdf
 
MWC/ADC 2013 Using the Nokia Music Windows Phone APIs
MWC/ADC 2013 Using the Nokia Music Windows Phone APIsMWC/ADC 2013 Using the Nokia Music Windows Phone APIs
MWC/ADC 2013 Using the Nokia Music Windows Phone APIs
 
RecordPlug & plugXchange
RecordPlug & plugXchangeRecordPlug & plugXchange
RecordPlug & plugXchange
 
Audio Analysis with Spotify's Web API
Audio Analysis with Spotify's Web APIAudio Analysis with Spotify's Web API
Audio Analysis with Spotify's Web API
 
I've Got a Key to Your API, Now What? (Joint PBS and NPR API Presentation Giv...
I've Got a Key to Your API, Now What? (Joint PBS and NPR API Presentation Giv...I've Got a Key to Your API, Now What? (Joint PBS and NPR API Presentation Giv...
I've Got a Key to Your API, Now What? (Joint PBS and NPR API Presentation Giv...
 
Attracted by the success of Spotify, a group of students wants to bu.pdf
Attracted by the success of Spotify, a group of students wants to bu.pdfAttracted by the success of Spotify, a group of students wants to bu.pdf
Attracted by the success of Spotify, a group of students wants to bu.pdf
 
I've got key to your API, now what?
I've got key to your API, now what?I've got key to your API, now what?
I've got key to your API, now what?
 
You are to consider the design of a web app to help a night .pdf
You are to consider the design of a web app to help a night .pdfYou are to consider the design of a web app to help a night .pdf
You are to consider the design of a web app to help a night .pdf
 
Application Programming Interfaces
Application Programming InterfacesApplication Programming Interfaces
Application Programming Interfaces
 
Music recommender app - Python with AI
Music recommender app - Python with AIMusic recommender app - Python with AI
Music recommender app - Python with AI
 
Last.fm API workshop - Stockholm
Last.fm API workshop - StockholmLast.fm API workshop - Stockholm
Last.fm API workshop - Stockholm
 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docx
 
3-4E Attracted by the success of Spotify- a group of students wants to.pdf
3-4E Attracted by the success of Spotify- a group of students wants to.pdf3-4E Attracted by the success of Spotify- a group of students wants to.pdf
3-4E Attracted by the success of Spotify- a group of students wants to.pdf
 
Problem 2 struct to hold information about a song struct So.pdf
 Problem 2 struct to hold information about a song struct So.pdf Problem 2 struct to hold information about a song struct So.pdf
Problem 2 struct to hold information about a song struct So.pdf
 
Unit 35: LO3
Unit 35: LO3Unit 35: LO3
Unit 35: LO3
 
Unit 35: LO3
Unit 35: LO3Unit 35: LO3
Unit 35: LO3
 
TECHNOLOGIES OF MUSIC
TECHNOLOGIES OF MUSICTECHNOLOGIES OF MUSIC
TECHNOLOGIES OF MUSIC
 
Wp dev day_using_the_nokia_music_apis
Wp dev day_using_the_nokia_music_apisWp dev day_using_the_nokia_music_apis
Wp dev day_using_the_nokia_music_apis
 
Lesson 1 nea brief annotations
Lesson 1   nea brief annotationsLesson 1   nea brief annotations
Lesson 1 nea brief annotations
 

Plus de aggarwalshoppe14

I really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfI really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdf
aggarwalshoppe14
 
I really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfI really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdf
aggarwalshoppe14
 
I need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfI need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdf
aggarwalshoppe14
 
I need help with the last 2 methods only in Huffman.java file the me.pdf
I need help with the last 2 methods only in Huffman.java file the me.pdfI need help with the last 2 methods only in Huffman.java file the me.pdf
I need help with the last 2 methods only in Huffman.java file the me.pdf
aggarwalshoppe14
 
I need help creating this flutter applicationPlease provide a com.pdf
I need help creating this flutter applicationPlease provide a com.pdfI need help creating this flutter applicationPlease provide a com.pdf
I need help creating this flutter applicationPlease provide a com.pdf
aggarwalshoppe14
 
Hile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdf
Hile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdfHile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdf
Hile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdf
aggarwalshoppe14
 
Hi could I get the java code for all the tasks pls, many thanks!.pdf
Hi could I get the java code for all the tasks pls, many thanks!.pdfHi could I get the java code for all the tasks pls, many thanks!.pdf
Hi could I get the java code for all the tasks pls, many thanks!.pdf
aggarwalshoppe14
 
Here are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfHere are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdf
aggarwalshoppe14
 
help write program Project Desoription The purpose of thi project i.pdf
help write program Project Desoription The purpose of thi project i.pdfhelp write program Project Desoription The purpose of thi project i.pdf
help write program Project Desoription The purpose of thi project i.pdf
aggarwalshoppe14
 
I need a case analysis using Harvards Business School format please.pdf
I need a case analysis using Harvards Business School format please.pdfI need a case analysis using Harvards Business School format please.pdf
I need a case analysis using Harvards Business School format please.pdf
aggarwalshoppe14
 

Plus de aggarwalshoppe14 (20)

I am sure you have heard the adage �my word is my bond�. We do not k.pdf
I am sure you have heard the adage �my word is my bond�. We do not k.pdfI am sure you have heard the adage �my word is my bond�. We do not k.pdf
I am sure you have heard the adage �my word is my bond�. We do not k.pdf
 
I really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdfI really need some help if I have this right so far. Please Resub.pdf
I really need some help if I have this right so far. Please Resub.pdf
 
I receive this answer for one of my questions, I need the reference .pdf
I receive this answer for one of my questions, I need the reference .pdfI receive this answer for one of my questions, I need the reference .pdf
I receive this answer for one of my questions, I need the reference .pdf
 
I really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdfI really need some help if I have this right so far. PLEASE CHANG.pdf
I really need some help if I have this right so far. PLEASE CHANG.pdf
 
I need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdfI need this code, to show ALL inventory items, then with the remove .pdf
I need this code, to show ALL inventory items, then with the remove .pdf
 
I need help with the last 2 methods only in Huffman.java file the me.pdf
I need help with the last 2 methods only in Huffman.java file the me.pdfI need help with the last 2 methods only in Huffman.java file the me.pdf
I need help with the last 2 methods only in Huffman.java file the me.pdf
 
I need help creating this flutter applicationPlease provide a com.pdf
I need help creating this flutter applicationPlease provide a com.pdfI need help creating this flutter applicationPlease provide a com.pdf
I need help creating this flutter applicationPlease provide a com.pdf
 
His Majesty�s Government report that 20 of officials arrive late fo.pdf
His Majesty�s Government report that 20 of officials arrive late fo.pdfHis Majesty�s Government report that 20 of officials arrive late fo.pdf
His Majesty�s Government report that 20 of officials arrive late fo.pdf
 
HIVin RNA genomu, bir RNA ablonundan bir DNA genomunu sentezlemek i.pdf
HIVin RNA genomu, bir RNA ablonundan bir DNA genomunu sentezlemek i.pdfHIVin RNA genomu, bir RNA ablonundan bir DNA genomunu sentezlemek i.pdf
HIVin RNA genomu, bir RNA ablonundan bir DNA genomunu sentezlemek i.pdf
 
Hile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdf
Hile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdfHile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdf
Hile ��geni bileenlerini a�klar. Tannm bir kriminolog olan Donald .pdf
 
Hi, I need help with this Probability question. Please show work and.pdf
Hi, I need help with this Probability question. Please show work and.pdfHi, I need help with this Probability question. Please show work and.pdf
Hi, I need help with this Probability question. Please show work and.pdf
 
Hi could I get the java code for all the tasks pls, many thanks!.pdf
Hi could I get the java code for all the tasks pls, many thanks!.pdfHi could I get the java code for all the tasks pls, many thanks!.pdf
Hi could I get the java code for all the tasks pls, many thanks!.pdf
 
HHI analysis indicates that many states have a highly concentrated i.pdf
HHI analysis indicates that many states have a highly concentrated i.pdfHHI analysis indicates that many states have a highly concentrated i.pdf
HHI analysis indicates that many states have a highly concentrated i.pdf
 
Hello I need help configuring the regression equation for this scatt.pdf
Hello I need help configuring the regression equation for this scatt.pdfHello I need help configuring the regression equation for this scatt.pdf
Hello I need help configuring the regression equation for this scatt.pdf
 
Health Economics with Taxation and Agrarian ReformActivity 2 Grap.pdf
Health Economics with Taxation and Agrarian ReformActivity 2 Grap.pdfHealth Economics with Taxation and Agrarian ReformActivity 2 Grap.pdf
Health Economics with Taxation and Agrarian ReformActivity 2 Grap.pdf
 
Here is a short amino acid sequence mapped as polar (P) and nonpolar.pdf
Here is a short amino acid sequence mapped as polar (P) and nonpolar.pdfHere is a short amino acid sequence mapped as polar (P) and nonpolar.pdf
Here is a short amino acid sequence mapped as polar (P) and nonpolar.pdf
 
Here are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdfHere are the instructions and then the code in a sec. Please R.pdf
Here are the instructions and then the code in a sec. Please R.pdf
 
help write program Project Desoription The purpose of thi project i.pdf
help write program Project Desoription The purpose of thi project i.pdfhelp write program Project Desoription The purpose of thi project i.pdf
help write program Project Desoription The purpose of thi project i.pdf
 
I need a case analysis using Harvards Business School format please.pdf
I need a case analysis using Harvards Business School format please.pdfI need a case analysis using Harvards Business School format please.pdf
I need a case analysis using Harvards Business School format please.pdf
 
Household size and educational status are part of ���� Psychologic.pdf
Household size and educational status are part of ���� Psychologic.pdfHousehold size and educational status are part of ���� Psychologic.pdf
Household size and educational status are part of ���� Psychologic.pdf
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

Here is app.js, artist.js and songs.js file. Can you look at the my .pdf

  • 1. Here is app.js, artist.js and songs.js file. Can you look at the my code and point any error in it. As the assignment requirement, when the button is clicked, it show artist name, link and songs, but mine only show name and link. I need to help in showing the song table. /** * artists.js * * The app's list of Artists */ window.artists = [ { id: "a1", name: "Ingrid Michaelson", link: [ { url: "https://www.instagram.com/ingridmichaelson/?hl=en", name: "Instagram" }, { url: "https://twitter.com/ingridmusic", name: "Twitter" }, { url: "https://open.spotify.com/artist/2vm8GdHyrJh2O2MfbQFYG0", name: "Spotify" } ] }, { id: "a2", name: "Katie Melua", link: [ { url: "https://www.instagram.com/katiemeluaofficial/?hl=en", name: "Instagram"
  • 2. }, { url: "https://twitter.com/katiemelua", name: "Twitter" }, { url: "https://open.spotify.com/artist/5uCXJWo3WoXgqv3T1RlAbh", name: "Spotify" } ] }, { id: "a3", name: "Birdy", link: [ { url: "https://www.instagram.com/birdyinstagram/?hl=en", name: "Instagram" }, { url: "https://twitter.com/birdy?lang=en", name: "Twitter" }, { url: "https://open.spotify.com/artist/2WX2uTcsvV5OnS0inACecP", name: "Spotify" } ] } ]; /** * songs.js * * The app's songs */
  • 3. window.songs = [ { id: "s1", artistId: "a1", title: "The Way I Am", year: "2007", duration: "135", flagged: "false" }, { id: "s2", artistId: "a1", title: "You And I", year: "2008", duration: "148", flagged: "false" }, { id: "s3", artistId: "a1", title: "Everybody", year: "2009", duration: "209", flagged: "false" }, { id: "s4", artistId: "a1", title: "Girls Chase Boys", year: "2014", duration: "221", flagged: "false" }, { id: "s5",
  • 4. artistId: "a1", title: "Afterlife", year: "2014", duration: "281", flagged: "false" }, { id: "s6", artistId: "a1", title: "Time Machine", year: "2019", duration: "212", flagged: "true" }, { id: "s7", artistId: "a1", title: "The Lotto", year: "2020", duration: "193", flagged: "false" }, { id: "s8", artistId: "a2", title: "Nine Million Bicycles", year: "2005", duration: "195", flagged: "false" }, { id: "s9", artistId: "a2", title: "Piece By Piece", year: "2005", duration: "204",
  • 5. flagged: "false" }, { id: "s10", artistId: "a2", title: "Wonderful Life", year: "2010", duration: "244", flagged: "false" }, { id: "s11", artistId: "a2", title: "All Over The World", year: "2012", duration: "176", flagged: "false" }, { id: "s12", artistId: "a2", title: "Dreams On Fire", year: "2016", duration: "245", flagged: "false" }, { id: "s13", artistId: "a2", title: "Joy", year: "2020", duration: "193", flagged: "false" }, { id: "s14",
  • 6. artistId: "a2", title: "Quiet Moves", year: "2023", duration: "218", flagged: "true" }, { id: "s15", artistId: "a3", title: "Skinny Love", year: "2011", duration: "203", flagged: "false" }, { id: "s16", artistId: "a3", title: "People Help the People", year: "20111", duration: "256", flagged: "false" }, { id: "s17", artistId: "a3", title: "Wings", year: "2013", duration: "252", flagged: "false" }, { id: "s18", artistId: "a3", title: "All You Never Say", year: "2013", duration: "278",
  • 7. flagged: "true" }, { id: "s19", artistId: "a3", title: "Keep Your Head Up", year: "2016", duration: "208", flagged: "false" }, { id: "s20", artistId: "a3", title: "Beautiful Lies", year: "2016", duration: "170", flagged: "true" }, { id: "s21", artistId: "a3", title: "Second Hand News", year: "2021", duration: "248", flagged: "false" }, { id: "s22", artistId: "a3", title: "Young Heart", year: "2021", duration: "358", flagged: "false" } ]; // All of our data is available on the global `window` object.
  • 8. // Create local variables to work with it in this file. const { artists, songs } = window; // Create a reference to the nav element of the menu document.addEventListener(`DOMContentLoaded`, function () { const menu = document.querySelector("#menu"); const songTable = document.querySelector("#songs"); // Loop through each artist in the artists array for (let i = 0; i < artists.length; i++) { const artist = artists[i]; const button = document.createElement("button"); button.textContent = artist.name; button.onclick = function () { updatedArtist(artist); }; menu.appendChild(button); } // Get the current artist function updatedArtist(artist) { const artistName = document.getElementById("selected-artist"); artistName.textContent = artist.name; artistName.innerHTML += artist.link .map((link) => { return ` ${link.name}`; }) .join(","); songTable.querySelector("tbody").innerHTML = ""; // Get all songs for the current artist const artistSongs = songs.filter(function (s) { return s.artists.includes(artist.id) && !s.flagged; });
  • 9. // Loop through each song in the song array artistSongs.forEach(function (song) { const row = document.createElement("tr"); row.addEventListener(`click`, function () { console.log(song.title); }); const colId = document.createElement("td"); colId.textContent = song.id; row.appendChild(colId); const colTitle = document.createElement("td"); colTitle.textContent = song.title; row.appendChild(colTitle); const colYear = document.createElement("td"); colYear.textContent = song.year; row.appendChild(colYear); const colDuration = document.createElement("td"); colDuration.textContent = formatDuration(song.duration); songTable.querySelector("tbody").appendChild(row); }); function formatDuration(totalSecond) { var minutes = Math.floor(totalSecond / 60); var seconds = totalSecond % 60; if (seconds < 10) { seconds = "0" + seconds; } return minutes + ":" + seconds; } } }); // For debugging, display all of our data in the console. You can remove this later. console.log({ artists, songs }, "App Data") Overview This assignment is designed to have you practice working with HTML and the DOM in order to create both static and dynamic web content. You are asked to prototype a fictional
  • 10. Music App. Your app will focus on a specific music genre and allow users to browse different artists and find specific songs. Because your app's artists and songs will change frequently, we often separate our data from its UI representation. This allows us to quickly make changes and have the app always use the most current music catalogue. NOTE: in a reaf music app, our data would be stored in a database. We will simulate working with a database by using JavaScript Objects and Arrays in separate files. Pick Your Music Genre and Artists, Songs You need to decide on the following details for your app: - Music Genre: your music app is going to focus on a particular type of music. What is it? You could use the same type of music as you chose in Assignment 3 or pick another. - Name: what is your app called? Pick something unique and relevant to your chosen music genre. - Slogan: what is your store's slogan (i.e., a short description)? This will help a user to determine if your music app is worth using. - Artists: which music artists/bands does your app include? Based on your chosen music genre, pick at least 3 artists that make this type of music. No two students can use the exact same set of artists. - Songs: pick a minimum of 20 songs by your chosen artists. Each song will belong to one of the artists. Each song needs the following things: - id: a unique String that identifies this song. For example: "s 1 " or "song-01" or "V1StGXR8". It doesn't matter what format you choose as long as each song has its own, unique value. Also, make sure the artist id and song id are different. - artistld: a String that indicates which artist this song belongs to - title: a short String that names the song - year: a String with the year (4 digits) that the song was recorded - duration: a Number of seconds (i.e., an Integer value) for the song's length. When we store time values, we often store them in seconds vs. floats, and convert them to minutes, seconds in the UI for display. - flagged: a Boolean that indicates whether this song has been flagged in the system, and should NOT be shown to users. Make sure at least 2 of your songs have flagged set to true. Your artist and song data will go in 'src/artists.js' and 'src/songs.js' respectively. See these files for technical details about how to code your data. Take some time now to enter all of your app's data. Store Web Site HTML Your app's HTML file is located in 'src/index.html'. A brief HTML skeleton has been created, and you are asked to fill in the rest using your information above. Some of your site will be static (i.e., coded in HTML directly in index.html) and never change. Other parts of the site will be dynamic (i.e., created using DOM API calls at run-time) and will update in response to various events and user actions. Here is a basic wireframe of what your site needs to include, and which parts are static or dynamic. NOTE: don't worry too much about how it looks. Focus on the structure and functionality. Artist1 Name (Twitter, Instagram, SoundCloud)
  • 11. 1. Create an event handler to run when the page is loaded. Make sure you don't do anything to the DOM until it's fully loaded. Your function should do the following: a. Create all of the buttons for your store's Artists i. Loop through all of your Artist objects and create a< button > element for each, adding it to the nav id = "menu" > ii. Use each Artist's name for the button's text iii. When the button is clicked, show that Artists Name, Links, and Songs. See below for more details. b. Show a list of Songs in the tbody > of your Table. By default, you should use your first Artist on load. See below for more details 2. Write a function that will show a list of songs in the < tbody rows from the tbody >. HINT: inner HTML =un c. Filter your Songs Array (i.e., use Array.prototype.filter(j) to get: i. All Songs for the chosen Artist. HINT: use Array.prototype.includes() ii. All Songs that are NOT flagged d. Loop (use Array.prototype.forEach(h) over your filtered song list and add them to the table's body using DOM methods (i.e., not innerHTML): i. Create atr> element 1. Add a click handler to your that will console.log() the song whenever the user clicks it ii. Create elements for the song's name, year, and duration. Convert the duration in seconds to a value in mintues:seconds iii. Append these td> elements to the < tr > iv. Append this < tr > to the < tbody> In your solution, you will likely require all of the following: - console. log() and NOTE that you can log Objects like so: console.log({ object }) - document.querySelector(j) to find elements in the DOM - document.createElement() to create new DOM elements - node.appendChild() to add an element as a child of a DOM node - element.innerHTML to modify the HTML content of an element. Don't overuse this!