1
I’m making a code that generates a Pascal triangle for a project of mine, but when I spin it gets stuck, as if the is infinite.
function pascal(n) {
var d;
var uau = "";
var line;
var i;
for(line = 1; line += 1; line <= n){
d = 1;
for(i = 1; i += 1; i <= line){
uau += d.toString();
d *= (line - i) / i;
}
uau += "<br>";
};
return uau;
}
$("#uau").click(function(){
var n = $("#inp").val();
document.write(pascal(n));
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>teste</title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
</head>
<body>
<form>
<input type="number" id="inp">
<button type="button" id="uau">UAU</button>
</form>
</body>
</html>
Thank you, you saved me
– Arthur Bacci