From 0b3e2931cfe4f252720db32957dc982ac893182a Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Fri, 20 Dec 2019 01:10:32 -0500 Subject: fixed and simplified Space.comb --- space.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/space.js b/space.js index f5bf041..171df6c 100644 --- a/space.js +++ b/space.js @@ -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]); } } } -- cgit