Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
javascript_fundamentals
Project
Project
Details
Activity
Releases
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
Shaphen Pangburn
javascript_fundamentals
Commits
80200193
Commit
80200193
authored
Apr 09, 2021
by
Shaphen Pangburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete assignment for JavaScript Basics
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
0 deletions
+124
-0
index.html
index.html
+57
-0
js_practice.js
js_practice.js
+51
-0
js_refresher.js
js_refresher.js
+16
-0
No files found.
index.html
0 → 100644
View file @
80200193
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Javascript Practice
</title>
<script
src=
"js_refresher.js"
></script>
<script
src=
"js_practice.js"
></script>
<script>
function
speak
()
{
document
.
write
(
" /o/"
);
}
let
introduction
=
name
=>
{
document
.
write
(
"Hi my name is "
+
name
);
}
</script>
</head>
<body>
<h1>
Hello friends
</h1>
<script>
document
.
write
(
"Oh hi there!"
);
// print statement
speak
();
// called function from the header
</script>
<br>
<script>
myFunction
();
// called from ./javascript_refresher.js
</script>
<br>
<script>
counter
(
10
);
// called from ./javascript_refresher.js
</script>
<br>
<script>
document
.
write
(
thing
)
// using a global variable
</script>
<br>
<script>
introduction
(
"Chef"
)
// function created using anonymous function
</script>
<br>
<script>
(
function
(
message
)
{
document
.
write
(
`This is a special message:
${
message
}
`
);
})(
"I'm a potato"
);
// anonymous function that immediately invokes
</script>
<br>
<script>
functionOne
();
// functionTwo(); will throw error because not in scope
</script>
</body>
</html>
js_practice.js
0 → 100644
View file @
80200193
// nested functions / scope
function
functionOne
()
{
console
.
log
(
"first function"
)
function
functionTwo
()
{
console
.
log
(
"Nested function"
);
}
}
// incrementation and operators
let
a
=
10
;
console
.
log
(
a
);
// 10
console
.
log
(
a
++
);
// 10
console
.
log
(
a
);
// 11
console
.
log
(
++
a
);
// 12
console
.
log
(
"-"
);
console
.
log
(
a
+=
1
);
// 13
console
.
log
(
a
-=
1
);
// 12
console
.
log
(
a
*=
2
);
// 24
console
.
log
(
a
/=
2
);
// 12
console
.
log
(
"-"
);
// loops and conditionals
let
i
=
true
;
while
(
i
==
false
)
{
console
.
log
(
"I wont show"
);
}
let
j
=
true
;
do
{
console
.
log
(
"I will show"
);
}
while
(
j
==
false
);
console
.
log
(
"-"
);
let
arr
=
[
"Pradeep"
,
"Kevin"
,
"Shanelle"
,
"Ben"
,
"Nikitha"
,
"Vishal"
]
for
(
const
engineerIdx
in
arr
)
{
console
.
log
(
engineerIdx
);
}
console
.
log
(
"-"
);
for
(
const
engineer
of
arr
)
{
console
.
log
(
engineer
);
}
js_refresher.js
0 → 100644
View file @
80200193
// variable declaration
thing
=
"ok bye"
;
console
.
log
(
thing
);
// function declarations
function
myFunction
()
{
document
.
write
(
"I'm here too!"
)
}
function
counter
(
max
)
{
for
(
let
i
=
0
;
i
<=
max
;
i
++
)
{
console
.
log
(
i
);
document
.
write
(
i
);
}
}
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