We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Basic Variables

The var keyword declares a variable the sad way. For example:

var mySkillIssues = 42;

Some of JavaScript's most common variable types are:

  • number: represents both integer and floating-point numbers
  • boolean: either true or false
  • string: a sequence of characters
  • undefined: a variable that hasn't been assigned a value
var smsSendingLimit = 100;
var isAdmin = true;
var username = "wagslane";
var nothing = undefined;

Don't worry, we'll talk about a better way to declare variables in the next lesson.

Assignment

Run (but don't submit yet) the code. Notice that the username is blank!

Set the username variable to the value "eddie_cabot". Then submit the fixed code.