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
e97d860f
Commit
e97d860f
authored
5 years ago
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If / else statements
parent
afd9ae29
master
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
script.js
script.js
+33
-2
No files found.
script.js
View file @
e97d860f
...
@@ -72,7 +72,7 @@ console.log(typeof x);
...
@@ -72,7 +72,7 @@ console.log(typeof x);
/*****************************
/*****************************
* Operator precedence
* Operator precedence
*/
*/
/*
var now = 2018;
var now = 2018;
var yearJohn = 1989;
var yearJohn = 1989;
var fullAge = 18;
var fullAge = 18;
...
@@ -95,3 +95,34 @@ x += 10;
...
@@ -95,3 +95,34 @@ x += 10;
console.log(x);
console.log(x);
x--;
x--;
console.log(x);
console.log(x);
*/
/*****************************
* If / else statements
*/
var
firstName
=
'John'
;
var
civilStatus
=
'single'
;
if
(
civilStatus
===
'married'
)
{
console
.
log
(
firstName
+
' is married!'
);
}
else
{
console
.
log
(
firstName
+
' will hopefully marry soon :)'
);
}
var
isMarried
=
true
;
if
(
isMarried
)
{
console
.
log
(
firstName
+
' is married!'
);
}
else
{
console
.
log
(
firstName
+
' will hopefully marry soon :)'
);
}
var
massMark
=
78
;
// kg
var
heightMark
=
1.69
;
// meters
var
massJohn
=
92
;
var
heightJohn
=
1.95
;
var
BMIMark
=
massMark
/
(
heightMark
*
heightMark
);
var
BMIJohn
=
massJohn
/
(
heightJohn
*
heightJohn
);
if
(
BMIMark
>
BMIJohn
)
{
console
.
log
(
'Mark
\'
s BMI is higher than John
\'
s.'
);
}
else
{
console
.
log
(
'John
\'
s BMI is higher than Marks
\'
s.'
);
}
This diff is collapsed.
Click to expand it.
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