Skip to content

Commit b85279f

Browse files
committed
array travesing practice with loop and fnction completed
1 parent 4befdf0 commit b85279f

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

Array Travesing/index.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Document</title>
7-
</head>
8-
<body>
9-
7+
</head>
8+
<body>
9+
<form>
10+
<input type="number" name="" id="inp" />
11+
<button onclick="element()">Submit</button>
12+
</form>
1013
<script src="script.js"></script>
11-
</body>
12-
</html>
14+
</body>
15+
</html>

Array Travesing/script.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
console.log("Dsa With JS");
1+
// Array Travesing
2+
3+
const data = [42, 56, 52, 2, 54, 3, 7, 67, 3, 10, 0, 97];
4+
5+
// for (let i = 0; i < data.length; i++) {
6+
// console.log(data[i]);
7+
// };
8+
9+
function element() {
10+
const input = document.getElementById("inp").value;
11+
alert(data[input])
12+
};

0 commit comments

Comments
 (0)