You are almost correct at your end just need few updates...
<!--<html>
<head>
</head>
<body>
<input id="nume" type="number">
<input id="num" type="number">
<input type="button" onclick="MyFunction()" value="Click to calculate">
<p id="f">Value Is: 0</p>
</body>
<script>
const something = document.getElementById("nume")
const somethingElse = document.getElementById("num")
function MyFunction(){
var values = something + somethingElse;
document.getElementById("f").innerHTML = "Value Is: " + values
}
</script>-->
<html>
<head>
</head>
<body>
<input id="nume" type="number">
<input id="num" type="number">
<input type="button" onclick="MyFunction()" value="Click to calculate">
<p id="f">Value Is: 0</p>
</body>
<script>
const something = document.getElementById("nume")
const somethingElse = document.getElementById("num")
function MyFunction(){
var values = parseFloat(something.value) + parseFloat(somethingElse.value);
document.getElementById("f").innerHTML = "Value Is: " + values
}
</script>
You can use given code...which is not commented over here.
That is because the statement
const something = document.getElementById("num")
will return an html element in document with the id that you have given in () rounded brackets so if you are making an calculator you can use this statement...
something.value
because it will return the string value which is stored inside the html element in document with the id that you have given in () rounded brackets....now the problem is that you want to add those right?
so just use the math function parseFloat like this...
var values = parseFloat(something.value) + parseFloat(somethingElse.value);
so that you can cast them to float ... you can use parseInt also but i suggest to use the above statement..Now you can make a calculator easily...
Isn't it right? :)