diff options
author | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-20 01:10:32 -0500 |
---|---|---|
committer | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-20 01:10:32 -0500 |
commit | 0b3e2931cfe4f252720db32957dc982ac893182a (patch) | |
tree | 822b2893080a3703ff143e476ab67695ac8a3d7b | |
parent | 7e15df80062b805be9081128be32e6329632b61c (diff) |
fixed and simplified Space.comb
-rw-r--r-- | space.js | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -87,9 +87,11 @@ function Space(){ // CLASS // Iterate over other.data and add to this.data while (this.data.length < offset[0]+other.data.length) this.data.push([]); // Row padding for (let row = 0; row < other.data.length; row++){ - while (this.data.length < offset[1]+other.data.length) this.data.push(''); // Character-wise padding + let thisrow = this.data[row+offset[0]]; + while (thisrow.length < offset[1]+other.data[row].length) thisrow.push(''); // Character-wise padding for (let chr = 0; chr < other.data[row].length; chr++){ - this.data[row+offset[0]][chr+offset[1]] = func(this.data[row+offset[0]][chr+offset[1]], other.data[row][chr]); + let thechr = chr+offset[1]; + thisrow[thechr] = func(thisrow[thechr], other.data[row][chr]); } } } |