Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
javaScriptAssignment
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
Xiyang Lu
javaScriptAssignment
Commits
1b0deb84
Commit
1b0deb84
authored
Apr 09, 2021
by
Xiyang Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit add js practice
parent
767b49a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
0 deletions
+108
-0
demo1.html
demo1.html
+22
-0
demo2.html
demo2.html
+20
-0
practice.js
practice.js
+66
-0
No files found.
demo1.html
0 → 100644
View file @
1b0deb84
<html>
<head>
<title>
My First Program
</title>
<script
language =
"javascript"
type =
"text/javascript"
>
let
global
=
"this is global"
function
myFunction
()
{
let
local
=
"this is local"
return
local
}
</script>
</head>
<body>
<script>
document
.
write
(
global
)
document
.
write
(
myFunction
())
</script>
</body>
</html>
\ No newline at end of file
demo2.html
0 → 100644
View file @
1b0deb84
<html>
<body>
<h1>
JavaScript: Demonstrating function with parameters
</h1>
<script>
// Create a function which accepts two parameters
const
func
=
(
function
(
personName
,
session
)
{
return
"Hello "
+
personName
+
"! Welcome to "
+
session
;
})(
'Pradeep'
,
'JavaScript'
)
// Invoke the function with parameters
// var func = myFunction()
document
.
write
(
func
)
</script>
</body>
</html>
\ No newline at end of file
practice.js
0 → 100644
View file @
1b0deb84
// Variables - Scopes
let
global
=
"this is global"
function
myFunction
()
{
let
local
=
"this is local"
return
local
}
console
.
log
(
global
)
console
.
log
(
myFunction
())
//Functions
console
.
log
((
function
()
{
var
x
=
"Hello!!"
return
x
})())
// Operators
let
x
=
10
let
a
=
++
x
;
console
.
log
(
a
);
x
=
10
a
=
x
++
;
console
.
log
(
a
)
// Conditional statements
let
text
switch
(
new
Date
().
getDay
())
{
case
6
:
text
=
"Today is Saturday"
;
break
;
case
0
:
text
=
"Today is Sunday"
;
break
;
default
:
text
=
"Looking forward to the Weekend"
;
}
console
.
log
(
text
)
//Loops
var
i
=
0
;
for
(;
i
<
10
;
)
{
console
.
log
(
i
)
i
++
;
}
var
person
=
{
fname
:
"John"
,
lname
:
"Doe"
,
age
:
25
};
var
str
=
""
;
var
x
;
for
(
x
in
person
)
{
str
+=
person
[
x
]
+
" "
;
}
console
.
log
(
str
)
let
cars
=
[
"BMW"
,
"Volvo"
,
"Mini"
];
let
text
=
""
;
for
(
let
x
of
cars
)
{
text
+=
x
+
" "
;
}
console
.
log
(
text
)
\ 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