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
6a472c1f
Commit
6a472c1f
authored
Oct 10, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Functions
parent
adb38bb1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
script.js
script.js
+30
-1
No files found.
script.js
View file @
6a472c1f
...
@@ -200,7 +200,7 @@ switch (true) {
...
@@ -200,7 +200,7 @@ switch (true) {
/*****************************
/*****************************
* Truthy and Falsy values and equality operators
* Truthy and Falsy values and equality operators
*/
*/
/*
// falsy values: undefined, null, 0, '', NaN
// falsy values: undefined, null, 0, '', NaN
// truthy values: NOT falsy values
// truthy values: NOT falsy values
var height;
var height;
...
@@ -214,4 +214,33 @@ if (height || height === 0) {
...
@@ -214,4 +214,33 @@ if (height || height === 0) {
if (height === '23') {
if (height === '23') {
console.log('The == operator does type coercion!');
console.log('The == operator does type coercion!');
}
}
*/
/*****************************
* Functions
*/
function
calculateAge
(
birthYear
)
{
return
2018
-
birthYear
;
}
var
ageJohn
=
calculateAge
(
1990
);
var
ageMike
=
calculateAge
(
1948
);
var
ageJane
=
calculateAge
(
1969
);
console
.
log
(
ageJohn
,
ageMike
,
ageJane
);
function
yearsUntilRetirement
(
year
,
firstName
)
{
var
age
=
calculateAge
(
year
);
var
retirement
=
65
-
age
;
if
(
retirement
>
0
)
{
console
.
log
(
firstName
+
' retires in '
+
retirement
+
' years.'
);
}
else
{
console
.
log
(
firstName
+
' is already retired.'
)
}
}
yearsUntilRetirement
(
1990
,
'John'
);
yearsUntilRetirement
(
1948
,
'Mike'
);
yearsUntilRetirement
(
1969
,
'Jane'
);
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