Skip to content

Instantly share code, notes, and snippets.

@sharynneazhar
Last active March 29, 2023 20:41
Show Gist options
  • Save sharynneazhar/9ce932a11916b8c5b0c8bd0481edd4fa to your computer and use it in GitHub Desktop.
Save sharynneazhar/9ce932a11916b8c5b0c8bd0481edd4fa to your computer and use it in GitHub Desktop.
JavaScript Data Types Practice

Javascript Data Types Exercises

Data Types

For each expression, predict what you think the output will be in a comment (//) without first running the command. Then run the expression in the console. Note the actual output in a comment and compare it with your prediction.

You may run these commands inside the Dev Tool console to double check your answer!

Example

typeof("15")
// Prediction: Number
// Actual: String

What is the output of each of the expressions below?

typeof(15)
// Prediction:
// Actual:

typeof(5.5)
// Prediction:
// Actual:

typeof(NaN)
// Prediction:
// Actual:

typeof("hello")
// Prediction:
// Actual:

typeof(true)
// Prediction:
// Actual:

typeof(1 != 2)
// Prediction:
// Actual:


"hamburger" + "s"
// Prediction:
// Actual:

"hamburgers" - "s"
// Prediction:
// Actual:

"1" + "3"
// Prediction:
// Actual:

"1" - "3"
// Prediction:
// Actual:

"johnny" + 5
// Prediction:
// Actual:

"johnny" - 5
// Prediction:
// Actual:

99 * "luftbaloons"
// Prediction:
// Actual:

What's going on in the second half of the previous question? Are there any "rules" we can pull from those examples?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment