WDI Fundamentals

WDI Fundamentals Unit 7


Your Turn Your Turn

Data Types and Variables Exercise


Instructions

  1. Write the code to perform the actions listed below in the "JavaScript" panel in the JS Bin editor.
  2. If you don't see the JS Bin below, please refresh the page.
  3. Click "Run" to run the code in the "Console" panel.
  4. After clicking "Run", to check variable values, type the variable name in the "Console" panel on the right and hit enter/return.

JS Bin on jsbin.com

Let's get started!

  1. Create a variable petName. Assign (give) it the value "Rover".
  2. Create a variable age. Assign it the value 8.
  3. Create a variable favoriteToy. Assign it the value "ball".
  4. Hit the "run" button in the "Console" panel and then check the values of the three variables you created by typing each variable name into the "Console" panel and hitting enter/return.
    • Example: petName;
  5. Update petName. The new value should be Arthur.
  6. Update age. The new age should be 5.
  7. Update favoriteToy. The new favorite toy should be "yarn".
  8. Hit the "run" button in the "Console" panel and then check the values of the three variables you created by typing each variable name into the "Console" panel and hitting enter/return.
    • Example: petName;
  9. In the "Console" panel, use the typeof command to find the type of data stored in each variable.
    • Example: typeof petName

Stuck? Check out the solutions for assistance


On to the next lesson!