Skip to content

Commit f1919f0

Browse files
Add HTML and JavaScript files for basic function examples and billing system functionality
1 parent a0a0b28 commit f1919f0

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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>Document</title>
7+
8+
<script>
9+
10+
// arrow function example
11+
const greet = () => {
12+
alert("Welcome to cwpc.in");
13+
};
14+
15+
16+
// calling the arrow function
17+
greet();
18+
19+
</script>
20+
21+
</head>
22+
<body>
23+
24+
</body>
25+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
console.log("This is a JavaScript file for VM testing with arrow functions.");
2+
3+
// arrow function example
4+
const greet = () => console.log("Good Morning");
5+
6+
greet();
7+
8+
// use arguments in arrow function
9+
const info = (Name, Age) => {
10+
console.log(`My name is ${Name} and age is ${Age}`);
11+
}
12+
13+
info("John", 30);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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>Document</title>
7+
8+
<script>
9+
10+
11+
function bill(price,gst){
12+
// convert inputs to numbers
13+
price = parseFloat(price);
14+
gst = parseFloat(gst);
15+
gst_amount = (price * gst) / 100;
16+
total = price + gst_amount;
17+
document.getElementById('priceResult').innerText = price;
18+
document.getElementById('gstResult').innerText = gst_amount;
19+
document.getElementById('totalResult').innerText = total;
20+
21+
}
22+
23+
</script>
24+
25+
</head>
26+
<body>
27+
28+
29+
<h1>Billing System</h1>
30+
<p>Enter Price: <input type="number" id="price" placeholder="Enter Price"></p>
31+
<p>Enter GST Percentage: <input type="number" id ="gst" placeholder="Enter GST Percentage"></p>
32+
33+
<h1>bill print </h1>
34+
<p>Price : <span id="priceResult"></span></p>
35+
<p>GST Amount : <span id="gstResult"></span></p>
36+
<p>Total Amount : <span id="totalResult"></span></p>
37+
38+
<button onclick="bill(document.getElementById('price').value,document.getElementById('gst').value)">Calculate Bill</button>
39+
40+
41+
42+
</body>
43+
</html>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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>Document</title>
7+
8+
<script>
9+
// basic function
10+
function msg(){
11+
12+
alert("welcome to cwpc.in")
13+
14+
}
15+
16+
//msg();
17+
18+
// function with parameters
19+
function add(a, b) {
20+
alert("The sum of " + a + " and " + b + " is: " + (a + b));
21+
}
22+
23+
24+
// calling the function with parameters
25+
//add(5, 10);
26+
//add(20, 30);
27+
28+
29+
// return function
30+
function multiply() {
31+
return 900;
32+
}
33+
34+
document.write(multiply())
35+
36+
</script>
37+
38+
</head>
39+
<body>
40+
<button onclick="msg()">Click Me</button>
41+
call with parameters: <br>
42+
<button onclick="add(15, 25)">Add 15 and 25</button><br>
43+
<button onclick="add(100, 200)">Add 100 and 200</button><br>
44+
45+
</body>
46+
</html>
File renamed without changes.

0 commit comments

Comments
 (0)