• What is a Variable
  • Defining a Variable







____________________________________________________________________________________________________________________________________________


What is a Variable

  • Variables are containers for storing data values subject to change
  • Fundamental to EVERY and ANY decent program (in any language)


  • Defining a Variable

  • Simply state the name of the variable, set equal to the desired value (numeric, text, whatever)

  • # define your variables
    x = 'ruffs'
    y = 24
    
    # print variables
    print(x)
    print(y)
    
    unicorn
    24
    
    %%js 
    
    // define variables 
    let x = 'ruffs'; // defines a var, can be updated but not re-declared in the same scope
    const u = 24; // defines a block-scoped constant, cannot be updated or re-declared.
    var w = ['h', 'i']; // defines a var, can be updated or re-declared. Its function-scoped
    
    // log variables in console
    console.log(x);
    console.log(u);
    console.log(w);