📜  1 aed in 卢比 - Html (1)

📅  最后修改于: 2023-12-03 14:59:02.097000             🧑  作者: Mango

1 AED in 卢比 (INR) - HTML

Introduction:

This is a small program that converts 1 United Arab Emirates Dirham (AED) to Indian Rupees (INR) using HTML. The program takes the current exchange rate between AED and INR and multiplies it by 1 to get the equivalent amount in INR.

Code snippet:
<!DOCTYPE html>
<html>
<head>
  <title>1 AED in INR - HTML</title>
</head>
<body>
  <h1>1 AED in INR</h1>

  <script>
    // Define the exchange rate as a constant
    const exchangeRate = 19.44;

    // Perform the conversion
    const aed = 1;
    const inr = aed * exchangeRate;

    // Display the result
    document.write("<p>1 AED is equivalent to " + inr.toFixed(2) + " INR</p>");
  </script>
</body>
</html>
Explanation:
  1. The HTML file starts with the <!DOCTYPE html> declaration, followed by the opening <html> tag.
  2. Inside the <head> tag, we set the title of the HTML page to "1 AED in INR - HTML".
  3. The <body> tag contains the content of the page.
  4. We use the <h1> tag to display the heading "1 AED in INR".
  5. Inside the <script> tag, we write JavaScript code to perform the currency conversion.
  6. The exchange rate between AED and INR is set as a constant variable named exchangeRate.
  7. We declare two variables: aed to store the amount in AED (here, it's 1), and inr to store the calculated equivalent amount in INR.
  8. The result is displayed using the document.write() function, which writes the HTML content inside the <body> tag.
  9. The output is a paragraph (<p>) that shows the converted value in the format "1 AED is equivalent to [converted_amount] INR", where [converted_amount] is rounded to 2 decimal places using the toFixed() method.

The program dynamically calculates and displays the equivalent amount of 1 AED in Indian Rupees using HTML and JavaScript.