-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.html
51 lines (41 loc) · 1.22 KB
/
test2.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Interview test </title>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Word Reversal</title>
</head>
<body>
<h1>Word Reversal</h1>
<input type="text" id="word" placeholder="Enter a word" required>
<button type="button" id="reverse-button">Reverse Word</button>
<p id="result"></p>
<script src="script.js"></script>
</body>
</html>
</html>
<script>
const wordInput = document.getElementById("word");
const reverseButton = document.getElementById("reverse-button");
const result = document.getElementById("result");
reverseButton.addEventListener("click", function() {
const inputWord = wordInput.value.trim();
// Function to reverse a word
function reverseWord(word) {
return word.split("").reverse().join("");
}
const reversedWord = reverseWord(inputWord);
result.textContent = reversedWord;
});
</script>
<p> </p>
</body>
</html>