Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Learning JavaScript
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MohammadAli Keshavarz
Learning JavaScript
Commits
61f3bb77
Commit
61f3bb77
authored
Oct 10, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic operators
parent
ea9bb4f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
script.js
script.js
+29
-1
No files found.
script.js
View file @
61f3bb77
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment