2 Example(s) of JavaScript toExponential functional


Description :

ToExponential function convert a number to an exponential notation


JavaScript toExponential functional Example - 1
<!DOCTYPE html>
<html>
 <head>
    <title>Welcome to LearnKode - A code learning platform</title>
</head>
  <body>

<button onclick="convertToExponential()">Display the exponential notation</button>

<p id="sample"></p>

<script>
function convertToExponential() {
    var num = 6.76789567;
    var result = num.toExponential();
    document.getElementById("sample").innerHTML = result;
}
</script>

      </body>
</html>

Output

Description :

ToExponential converts provided number to an exponential notation


JavaScript toExponential functional Example - 2
<!DOCTYPE html>
<html>
 <head>
    <title>Welcome to LearnKode - A code learning platform</title>
</head>
  <body>
 <p>Click the button to display the exponential notation of a specified number.</p>
<button onclick="convertToExponential()">Display the exponential notation</button>
<p id="sample"></p>
<script>
function convertToExponential() {
    var num = 6.76549;
    var result = num.toExponential(3);
    document.getElementById("sample").innerHTML = result;
}
</script>
      </body>
</html>

Output