Giter Site home page Giter Site logo

Unit 2 Project // Playlist [Medium]

Overview:

In this unit, coders will create a playlist. The playlist will display a list of information about different songs with images and links to play the songs.

To create this project, coders will create arrays to hold song information, use a for or forEach loop to iterate over the arrays, and display data to the screen.

They will use .push to add new songs to their playlist. Then, students will refactor their project to using objects instead of arrays to hold their data.

Set-Up

  1. Fork your own copy of the repl.
  2. Double-check that you are signed in with your GitHub account.

Planning

  1. Complete the planning document.
    • Look over Inspiration and Ideas
    • Fill out the Brainstorm section.
    • Fill out the Song Data section.
  2. Read through the HTML starter code to understand the organization and class names given.
  3. Read through the JavaScript starter code to determine where each given function is declared and where each given function is called.
  4. Declare variables for your display divs: the image url, song name, artist, and song link. Go back to the HTML to check that you are using the correct class names.

JavaScript: Storing Song Data

  1. Create and populate an array to store your image urls. Create three more arrays. One to store your song names, one for the artists, and a last one for the song links.

JavaScript: Loop and Display Data

  1. Loop through your images array and display the images to your songs in the correct div. Create three more loops. One for the song names, one for the artists, and a last one for the song links.

What to display your song data in:

  • images: <img> tag inside a <p> tag
  • song names: <p> tag
  • artist: <p> tag
  • song links: <a> tag inside a <p> tag

Note: There is a function called emptyDisplay. Determine where this should be placed in your code. Where does it make sense to call this function?

JavaScript: Add Song Data

  1. Declare a variable to save the user input of the image url. Declare three more variables that save user input: One for the song names, one for the artists, and a last one for the song links.

  2. Use .push() to add each input value to the correct array.

JavaScript: Refactor Arrays to Objects

  1. Comment out the arrays data.
  2. Create an object for each of your songs.
  3. Inside each object, add key/value pairs to store the image url, song name, artist, and song link.
  4. Create an array that stores all of the objects.

JavaScript: Refactor Loops to Display Info

  1. Update your addSongInfo function so the input values are saved in as values in a new object.
  2. Update your .push() so the input object is added to your array of objects.
  3. Update your loops based on your new array of objects.

Project Extensions:

  • Add in your own CSS to personalize your project.
  • Use .length to display how many songs are on your list.
  • Add a clear or delete button to clear songs on your list.
  • Refactor your project further by utilizing functions to simplify your code.
  • Add a shuffle button and functionality.

References/Tools

alessromero20's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.