Skip to content

Instantly share code, notes, and snippets.

@cosminpopescu14
Created June 1, 2019 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosminpopescu14/53551ed3136062c008ddde0f95846d6a to your computer and use it in GitHub Desktop.
Save cosminpopescu14/53551ed3136062c008ddde0f95846d6a to your computer and use it in GitHub Desktop.
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