Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compute square surface
<html>
<label>Introduceti dimesiunea laturii patratului </label><input type ="text" id="laturaPatrat"/><br/>
<button type="button" onclick="calculeazaArie()">Calculeaza arie</button>
<p id="rezultat"></p>
<script>
function calculeazaArie() {
let dimensiune = document.getElementById("laturaPatrat").value //citim ceea ce am introdus in text box
if (dimensiune < 0)
document.getElementById("rezultat").innerHTML = "Latura unui patrat nu poate fi negativa"
document.getElementById("rezultat").innerHTML = Math.pow(dimensiune, 2); //ridica la patrat. sau dimensiune * dimensiune
}
</script>
</html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.