Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9524d09

Browse files
function
1 parent 79c0599 commit 9524d09

File tree

3 files changed

+168
-0
lines changed

3 files changed

+168
-0
lines changed

‎Function/app.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Function ? Function is a block of code that run particular task
2+
3+
//Types Of Function
4+
5+
//1.Function with function keyword
6+
7+
function hello(){
8+
console.log("Hello World");
9+
}
10+
11+
//2.Anonymous Function
12+
13+
var myFunction = function(){
14+
console.log("Say My Function");
15+
}
16+
17+
//SetInterval(function(){},1000)
18+
19+
//3.Arrow Function
20+
let greetings = () => console.log("Say Greetings");
21+
greetings();
22+
23+
//Parameters And Arguments
24+
25+
function sum(a,b){ // a , b are parameters
26+
let total = a + b ;
27+
return total;
28+
}
29+
30+
//Invokation or Declaration
31+
console.log(sum(5,10)); //Arguments
32+
33+
// let array = ["a","b"];
34+
// console.log(array.push("c"));
35+
36+
// function isEven(num){
37+
// if(num % 2 == 0){
38+
// return true;
39+
// }else{
40+
// return false;
41+
// }
42+
// }
43+
// console.log(isEven(10));
44+
// console.log(isEven(7));
45+
46+
let input = document.getElementById('num');
47+
let answer = document.getElementById('answer');
48+
49+
function isEven() {
50+
let num = input.value;
51+
console.log(num);
52+
if(num % 2 == 0){
53+
answer.innerText = "Even Number"
54+
55+
}else{
56+
answer.innerText = "Odd Number"
57+
58+
}
59+
60+
}
61+
62+
let num1 = document.getElementById('num1');
63+
let num2 = document.getElementById('num2');
64+
let result = document.getElementById('Calculation_Result')
65+
66+
function calculate(sign){
67+
let num1Value = parseInt(num1.value);
68+
let num2Value = parseInt(num2.value);
69+
console.log(sign,num1Value,num2Value);
70+
71+
if(sign == '+'){
72+
result.innerText = "Result " + (num1Value + num2Value);
73+
}else if(sign == '-'){
74+
result.innerText = "Result " + (num1Value - num2Value);
75+
}else if(sign == '*'){
76+
result.innerText = "Result " + (num1Value * num2Value);
77+
}else if(sign == '/'){
78+
result.innerText = "Result " + (num1Value / num2Value);
79+
}
80+
81+
}

‎Function/index.html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Function</title>
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
background: #f4f4f4;
11+
text-align: center;
12+
padding-top: 50px;
13+
}
14+
15+
.calculator {
16+
background: #fff;
17+
display: inline-block;
18+
padding: 30px;
19+
border-radius: 10px;
20+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
21+
}
22+
23+
input {
24+
padding: 10px;
25+
margin: 10px;
26+
width: 200px;
27+
border: 1px solid #ccc;
28+
border-radius: 5px;
29+
font-size: 16px;
30+
}
31+
32+
button {
33+
padding: 10px 20px;
34+
margin: 5px;
35+
font-size: 16px;
36+
border: none;
37+
background: #007BFF;
38+
color: white;
39+
border-radius: 5px;
40+
cursor: pointer;
41+
}
42+
43+
button:hover {
44+
background: #0056b3;
45+
}
46+
47+
#Calculation_Result {
48+
display: block;
49+
margin: 20px 0;
50+
font-size: 20px;
51+
font-weight: bold;
52+
color: #333;
53+
}
54+
</style>
55+
</head>
56+
<body>
57+
<h1 style="text-align: center;">Check Console Please ( Ctrl + Shift + i )</h1>
58+
<!-- <input type="text" id="num" placeholder="Enter Number">
59+
<button onclick="isEven()">Check</button>
60+
<h2 id="answer"></h2> -->
61+
<div>
62+
<input type="text" id="num1" placeholder="Enter First Number">
63+
<input type="text" id="num2" placeholder="Enter Second Number">
64+
<br>
65+
<span id="Calculation_Result"></span>
66+
<div>
67+
<button onclick="calculate('+')">Add</button>
68+
<button onclick="calculate('-')">Subs</button>
69+
<button onclick="calculate('*')">Multi</button>
70+
<button onclick="calculate('/')">Divi</button>
71+
</div>
72+
</div>
73+
<script src="app.js"></script>
74+
</body>
75+
</html>

‎Index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ <h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"
5959
</svg>
6060
</a>
6161
</div>
62+
<div class="max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700">
63+
<a href="#">
64+
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Function</h5>
65+
</a>
66+
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
67+
<a href="Function/index.html" class="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
68+
Read more
69+
<svg class="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
70+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>
71+
</svg>
72+
</a>
73+
</div>
6274
</div>
6375

6476
</body>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /