Commit 61f3bb77 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

Basic operators

parent ea9bb4f7
...@@ -21,7 +21,7 @@ var johnMark = 'John and MArk'; ...@@ -21,7 +21,7 @@ var johnMark = 'John and MArk';
/***************************** /*****************************
* Variable mutation and type coercion * Variable mutation and type coercion
*/ */
/*
var firstName = 'John'; var firstName = 'John';
var age = 28; var age = 28;
// Type coercion // Type coercion
...@@ -36,4 +36,32 @@ job = 'driver'; ...@@ -36,4 +36,32 @@ job = 'driver';
alert(firstName + ' is a ' + age + ' year old ' + job + '. Is he married? ' + isMarried); alert(firstName + ' is a ' + age + ' year old ' + job + '. Is he married? ' + isMarried);
var lastName = prompt('What is his last Name?'); var lastName = prompt('What is his last Name?');
console.log(firstName + ' ' + lastName); console.log(firstName + ' ' + lastName);
*/
/*****************************
* Basic operators
*/
var year, yearJohn, yearMark;
now = 2018;
ageJohn = 28;
ageMark = 33;
// Math operators
yearJohn = now - ageJohn;
yeahMark = now - ageMark;
console.log(yearJohn);
console.log(now + 2);
console.log(now * 2);
console.log(now / 10);
// Logical operators
var johnOlder = ageJohn < ageMark;
console.log(johnOlder);
// typeof operator
console.log(typeof johnOlder);
console.log(typeof ageJohn);
console.log(typeof 'Mark is older tha John');
var x;
console.log(typeof x);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment