FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Basic-To-Advanced-JavaScript/Function/app.js at main · MaazWebDev/Basic-To-Advanced-JavaScript · GitHub
MaazWebDev
/
Basic-To-Advanced-JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Basic-To-Advanced-JavaScript
/
Function
/
app.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (60 loc) · 1.75 KB
Breadcrumbs
Basic-To-Advanced-JavaScript
/
Function
/
app.js
Copy path
File metadata and controls
81 lines (60 loc) · 1.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Function ? Function is a block of code that run particular task
//Types Of Function
//1.Function with function keyword
function
hello
(
)
{
console
.
log
(
"Hello World"
)
;
}
//2.Anonymous Function
var
myFunction
=
function
(
)
{
console
.
log
(
"Say My Function"
)
;
}
//SetInterval(function(){},1000)
//3.Arrow Function
let
greetings
=
(
)
=>
console
.
log
(
"Say Greetings"
)
;
greetings
(
)
;
//Parameters And Arguments
function
sum
(
a
,
b
)
{
// a , b are parameters
let
total
=
a
+
b
;
return
total
;
}
//Invokation or Declaration
console
.
log
(
sum
(
5
,
10
)
)
;
//Arguments
// let array = ["a","b"];
// console.log(array.push("c"));
// function isEven(num){
// if(num % 2 == 0){
// return true;
// }else{
// return false;
// }
// }
// console.log(isEven(10));
// console.log(isEven(7));
let
input
=
document
.
getElementById
(
'num'
)
;
let
answer
=
document
.
getElementById
(
'answer'
)
;
function
isEven
(
)
{
let
num
=
input
.
value
;
console
.
log
(
num
)
;
if
(
num
%
2
==
0
)
{
answer
.
innerText
=
"Even Number"
}
else
{
answer
.
innerText
=
"Odd Number"
}
}
let
num1
=
document
.
getElementById
(
'num1'
)
;
let
num2
=
document
.
getElementById
(
'num2'
)
;
let
result
=
document
.
getElementById
(
'Calculation_Result'
)
function
calculate
(
sign
)
{
let
num1Value
=
parseInt
(
num1
.
value
)
;
let
num2Value
=
parseInt
(
num2
.
value
)
;
console
.
log
(
sign
,
num1Value
,
num2Value
)
;
if
(
sign
==
'+'
)
{
result
.
innerText
=
"Result "
+
(
num1Value
+
num2Value
)
;
}
else
if
(
sign
==
'-'
)
{
result
.
innerText
=
"Result "
+
(
num1Value
-
num2Value
)
;
}
else
if
(
sign
==
'*'
)
{
result
.
innerText
=
"Result "
+
(
num1Value
*
num2Value
)
;
}
else
if
(
sign
==
'/'
)
{
result
.
innerText
=
"Result "
+
(
num1Value
/
num2Value
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL