It is nice, but I don't prefer "let" and "for" in javascript, so i tried re-writte it
or with JEST testing and doc in gitlab.com/pemasat/playground/-/bl...
I hope that you will like it.
I rewrite it in a simplest way
function pascal(rows) { if (rows === 1) { return [[1]]; } if (rows === 0) { return []; } const prev = pascal(rows - 1); const last = prev[prev.length - 1]; const next = [1]; for (let i = 0; i < last.length - 1; i++) { next.push(last[i] + last[i + 1]); } next.push(1); prev.push(next); return prev; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It is nice, but I don't prefer "let" and "for" in javascript, so i tried re-writte it
or with JEST testing and doc in gitlab.com/pemasat/playground/-/bl...
I hope that you will like it.
I rewrite it in a simplest way