Skip to content

Instantly share code, notes, and snippets.

@mmeigooni
Created February 7, 2017 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmeigooni/ec22cb3a72c1fc90f61fe717db53e05d to your computer and use it in GitHub Desktop.
Save mmeigooni/ec22cb3a72c1fc90f61fe717db53e05d to your computer and use it in GitHub Desktop.

Exercises

Basic Requirements

Numbers

  1. Enter the following expressions into your console.

    1 + 2
    3 * 5
    5 / 4 - 13
    5000 * 234
    1073 / 57 + 200
  2. Why are the values produced by the following two expressions different? What are they?

    3 + 2 * 4 - 1
    (3 + 2) * (4 - 1)
  3. Calculate how old you are in minutes using the console.

  4. What is the percentage of people in the class with brown hair? Use the console to find out.

  5. Try the following expressions in the console:

    6 % 2
    42 % 10
    5 % 2
    6 % 3
    7 % 4
    100 % 12

    What is the significance of the result? How does the % (modulus) operator work?

  6. Try the following:

    3 % 2
    4 % 2
    5 % 2
    6 % 2

    What do the results tell you about the first operand to the modulus operator?

Strings

  1. Write a string that represents your full name.

  2. Write a string that represents your favorite food.

  3. Use the + operator to combine (known as concatenation) two or more strings, e.g.:

    // Your first and last names
    "Josh" + " " + "Lehman"
    • Your first and last names (as shown above)
    • Your parents' full names
    • Your home town and state
  4. Fix the errors in the following strings:

    Where are all the quotes?
    'hmm something is not right"
    'Do other ' * 'operators work with string concatenation?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment