Variables Homework (Show what you know!)

Homework Problem: Understanding JavaScript Variables

Creating Variables

  1. Create three variables as an object variable:
    • A variable called studentName that stores your name as a string.
    • A variable called age that stores your age as a number.
    • A variable called isStudent that stores a boolean value indicating whether you are a student (use true or false).
    1. Create a function variable that displays that your favorite song is playing:

      • A variable called favoriteSong that stores the name of your favorite song.
      • A variable called songArtist that stores the song’s artist.
      • A function called playFavoriteSong that logs a message saying “Now playing [favoriteSong] by [songArtist]”.
  2. Using the variables you created, write a sentence using console.log() to display:
    • Your name.
    • Your age.
    • Whether you are a student.
    • An output that states that your favorite song is now playing

    Example output: My name is [Your Name], I am [Your Age] years old, and it is [true/false] that I am a student. Now playing Champion by Kanye West