Js Test1 (AK)
Js Test1 (AK)
Ans:- alert(): Displays a simple pop-up box with a message and an OK button. It's used to
h show information or warnings to the user.
Example: alert("Hello!");
c
prompt(): Displays a pop-up box that asks the user for input, along with a text field to
type in, and OK and Cancel buttons. It's used to get information from the user.
document.write(+i+"<br>");
}
</script>
<script>
function countVowels() {
let inputString = document.getElementById("inputString").value;
let vowelCount = 0;
const vowels = "aeiouAEIOU";
Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the
result.
Ans:-
<!DOCTYPE html>
<html lang="en">
d <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sort Three Numbers</title>
<script>
function sortNumbers() {
// Get the input values from prompt
var num1 = parseFloat(prompt("Enter the first number:"));
var num2 = parseFloat(prompt("Enter the second number:"));
var num3 = parseFloat(prompt("Enter the third number:"));
// Sorting logic
var sortedNumbers = [num1, num2, num3];
sortedNumbers.sort();