Struggling to speed up my Excel sheet creation time, currently taking over 20 seconds. I'm using the code below to compare three arrays and get the desired output:
for (let i = 0; i < this.arrayNumberOne[0].length; i++) {
let orangeOne = this.arrayNumberOne[0][i]['item_1'];
let orangeTwo = this.arrayNumberOne[0][i]['item_2'];
let orangeThree = orangeOne.concat(orangeTwo)
for (let k = 0; k < this.arrayNumberTwo[0].length; k++) {
let appleOne = this.arrayNumberTwo[0][k]['item_1'];
for (let j = 0; j < this.arrayNumberThree[0].length; j++) {
let grapeOne = this.arrayNumberThree[0][j]['item_1'];
let grapeTwo = this.arrayNumberThree[0][j]['item_2'];
let grapeThree = this.arrayNumberThree[0][j]['item_3'];
if (orangeThree == grapeOne && appleOne == grapeTwo) {
if (grapeThree == null || grapeThree == '') {
// print to response to excel
}
else if (grapeThree == 'sells') {
// print stuff to excel
}
else if (grapeThree == 'buys') {
// print stuff to excel
}
}
}
}
}
Considering hashmaps and interfaces but need help implementing them here. Open to suggestions on how to optimize the process.
Edit: