WDI Fundamentals

WDI Fundamentals Unit 7

Your Turn Your Turn

Expressions and Evaluations Exercise


  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. In the "JavaScript" panel, declare (create) a variable myNumber. Assign it the value 30.

    • After declaring the myNumber variable in the "JavaScript" panel, be sure to check to make sure you've done things correctly by hitting "Run" in the "Console" panel and then typing myNumber; in the "Console" panel and hitting the return/enter key to check its value. You'll want to do this after each step.

      Note: Ensure the type of this value is correct — Remember 30 and '30' are not the same! Here we want to store a number, so make sure that there are no quotes around the value.

  2. Reassign (update) the myNumber variable to 20.

  3. Use the += operator to add 5 to the current value of myNumber.
  4. Now create a second variable greeting and assign (give) it the value "Hello ".
  5. Create a third variable name and assign it the value "Margaret".
  6. Create a fourth variable sayHello. We want the variable to hold the value "Hello Margaret". Use the variables greeting and name along with the + to create this value (referred to as string concatenation).

Stuck? Check out the solutions for assistance.

Ready for another quiz? Here we go!