Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Compute square surface
<label>Introduceti dimesiunea laturii patratului </label><input type ="text" id="laturaPatrat"/><br/>
<button type="button" onclick="calculeazaArie()">Calculeaza arie</button>
<p id="rezultat"></p>
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
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.