Skip to main content

Command Palette

Search for a command to run...

Self review: Song selection - React Basic

Updated
1 min read
Self review: Song selection - React Basic
D

A passionate full-stack developer from @ePlus.DEV

  1. In plain JavaScript, how do you build an instance of the Audio constructor?

    • new Audio();

    • New Audio();

    • Audio();

  2. If an object instance of the Audio constructor is saved in a variable named “song”, what property on the “song” object can you use to check if the song is currently playing?

    • song.paused

    • song.pause();

    • song.play()

  3. What is wrong with this code?

     function toggle() {
         if(song.paused) {
             song.pause()
         } else {
             song.play()
         }
     }
    
    • The app's logic doesn't work. The code on line 3 and the code on line 5 should swap places.

    • The condition in the if statement is wrong. It should be:

      if(song.paused())

    • You need to have an else if condition, in between the if and else conditions.

React Basics

Part 2 of 18

In this module you will explore the basic structure and use of the React.js library. You will learn how to produce single page web applications using React components and to use JSX to style them.

Up next

Self review: Displaying images - React Basic

Is this code a correct way to import an image in React? import avatar from "./assets/avatar.png" function UserImage() { return ( <div> <img src={avatar} alt = "User image" /> < /di...