Variables

Data types to remeber when assigning thr Variable:

  1. Number: Floating point numbers, for decimals and integers
  2. String: Sequence of characters, used for text
  3. Boolean: Logical data type that can be true or false
  4. Undefined: Data type of a variable that does not have yet
  5. Undefined: Data type of a variable that does not have yet
  6. Null: Also means 'non-existent

Rules to choose Variable

  1. Names can contain letters, digits, underscores, and dollar signs
  2. Names must begin with a letter
  3. Names can also begin with $ and _ (but we will not use it in this tutorial)
  4. Names are case sensitive (y and Y are different variables)
  5. Reserved words (like JavaScript keywords) cannot be used as names

Example of Assiging Variables

var firstName = 'Roopak';
var lastName = 'Kumar';
var age = 26;
var job = 'Student'
var fullName = (firstName +' '+ lastName);
console.log('My name is ' + fullName + ' and I am ' + age + ' years old and I am a ' + job);

click 'Check' to see the answer