UX Design and Development course

Variable types

Let's learn different types of variables.

integers

var integer = 20;
console.log(integer);

floating point number

var floatingPoint = 20.4324243232;
console.log(floatingPoint);

Negative number

var negativeNumber = -101;
console.log(negativeNumber);

strings

Quotes tell JS that it is a string versus another variable. Use a backslash to escape characters within strings.

var string = 'This is a \'string\' of text';
console.log(string);

boolean variables == true or false

var trueFalse = true;
if (trueFalse === true) {
    console.log("It's true, it really is!");
} else {
    console.log('Nope, false YO!');
}

Playing with variables and strings

var name = "Dale";
var age = 40;
console.log(name + ' is my name, and I am ' + age + ' years old');

Play with code

JS Bin