Skip to content

Instantly share code, notes, and snippets.

@clairefields15
Last active February 18, 2021 18:49
Show Gist options
  • Save clairefields15/a5cc2a86e9894f7c3c7d51c414721add to your computer and use it in GitHub Desktop.
Save clairefields15/a5cc2a86e9894f7c3c7d51c414721add to your computer and use it in GitHub Desktop.
Claire_Fields_markdownPractice.md

Beginner's Guide to Data Types

Once you read this guide you will be well on your way to understanding the 4 different data types and how to use them in Javascript!

meme

1. String

  • A String is zero or more characters written within quotations.
  • Some examples of strings are:
    var favoriteFlower = "Rose"
    var typeOfTea = "Black"
    var myDogsName = "Jasmine"

2. Boolean

  • Boolean data represents one of two values: TRUE or FALSE.
  • It is typically used in combination with Boolean Logic to create if() statements in your code, such as:
var isOver21 = TRUE;
var isNotOver21 = FALSE;
if (isNotOver21) {
  alert ('You may not enter this website.');
}

3. Integers and Floats

  • Integers are whole numbers (not fractions) that can be positive, negative or zero.
  • Such as:
    var windchill = -25
    var myAge = 30
  • Floats are numbers that contain decimal points.
  • Such as:
    var savingsRate = 0.01
    var exactTemp = 98.6

4. Array

  • Arrays represent collections of data. They allow you to store multiple values in a single variable.
  • Some examples of arrays:
    var fruits = ["Banana", "Apple", "Cherry"]
    var numbers = [4, 6, 21, 43, 25, 28]
    var latteIngredients = ["Espresso", "Milk", "Foam", "Sugar"]

⚡️ TURN THIS SENTENCE INTO A LINK TO YOUR GIST ⚡️

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