JavaScript: parseFloat()



The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>JavaScript: Math.random()</title>
</head>
<body>
    
</body>
</html>
<h1 class="lesson-h1">JavaScript: parseFloat()</h1>

<div id="input-div">
<input type="text" name="user-text" id="user-text" placeholder="Enter Number or String">
</div><br>
<div id="buttons-div">
    <button id="button">parseFloat()</button>
</div>

<div id="numbers-div"></div>
<script>

const button = document.getElementById('button');

const numbersDiv = document.getElementById('numbers-div');

button.addEventListener('click', () => {
    console.log("Button pressed");
    const input = document.getElementById('user-text')
    const number = input.value;
    const parsedNumber = parseFloat(number);

    return numbersDiv.innerHTML = `<h2>${number}</h2><p>parseFloat() Result:</p><h2>${parsedNumber}</h2>`;

});
</script>
<?php
    include('../show_code.php');
    show_code('index.php');
?>   
</body>
</html>