I had a class in my code and I declared a constructor inside it...
constructor(rowNumber) {
this._rows = this.init(rowNumber);
}
get lastRow() {
return this._rows[this._rows.length - 1];
}
get rows() {
return this._rows;
}
fact(n) {
return (n > 1) ? this.fact(n - 1) * n : 1;
}
createRow(row) {
var result = [];
for (let i = 0; i <= row; i++) {
result.push(this.fact(row) / this.fact(i) / this.fact(row - i));
}
return result;
}
init(rowNumber) {
var result = [];
for (let i = 0; i < rowNumber; i++) {
result.push(this.createRow(i));
}
return result;
}
}
export {Triangle};
I declared init() function at the end of my code and I used init() in the constructor... if the constructor runs at first and then init() function runs ... does it cause a problem?