I have my code and it is working, but I'm trying to add the parseFloat option and 'toFixed()' to 2 decimal places. I'm confused on where these 2 lines of code should be placed. I created a unit conversion website that would convert the number of inches a user inputs and converts it to feet.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<center><title>Unit Coversion Table</title><center>
</head>
<body>
<div id="question">
<h2>Unit Convertor</h2>
<p>Enter a Quanity of Inches: <input id="userinches" type="number" /> </p>
</div> <!-- End of question div section -->
<div id="conversion">
<script>
function feet() {
var userinches = document.getElementById('userinches').value;
doOuput('The answer is ', userinches * 0.0833);
}
function doOuput(val, unit) {
document.getElementById('results').innerHTML = val + unit;
}
</script>
</div> <!-- End of conversion div section -->
<div="buttons">
<button type="button" id="buttonft" onclick="feet();">Feet</button>
</div> <!-- End of buttons div section -->
<div id="results"></div> <!-- End of results div section -->
</body>
</html>
You can do in either of the ways
Working fiddle https://codepen.io/Ashish9342/pen/YOOawR