If you want to know the changes of I and j in these two-layer cycles, how does the inner and outer cycles go?

                 for (let i = 0; i < this.temp1.length; iPP) {
                        let found = false;
                        for (let j = 0; j < combination_name_list.length; jPP) {
                            if (combination_name_list[j] == this.temp1[i].name) {
                                found = true;
                            }
                    if (j == combination_name_list.length - 1 && found == false) {
                                this.combination.push({
                                    "name": this.temp1[i].name,
                                    "rows1": this.temp1[i].rows,
                                    "rows2": [],
                                    "type": this.temp1[i].type
                                });
                            }
                        }
                    }

if you want to know the changes of I and j in these two-tier loops, how the inner and outer loops go, and the meaning of this code, you can only understand half of it!

May.22,2021

this is the difference

var temp1 = [{name:"a"},{name:"d"},{name:"c"}];
var combination_name_list = ['a'];

//
var combination = [{name:"d"},{name:"c"}];

combination_name_list what is stored in temp1 is name

.

is to take the first item in temp1 to combination_name_list to find no operation, but not to add this item to the new array combination , and so on the second item.


1. Outer loop traverses the array this.temp1

2. Perform a traversal of the this.temp1 array for each item of the combination_name_list array to see if there is a qualified option in the combination_name_list array (here it is judged by the value of the name field)

3. If you find a suitable option, set the found variable to true

.

4. If the last element traversing to combination_name_list still does not find a qualified option, add an element to the this.combination array


iterates through the temp1 and combination_name_list arrays, takes the last element of the combination_name_list array, and passes a set of current data to the combination array if and only if its value is not equal to the name value in the temp1 array.

Menu