JSFiddle - React, Tailwind, and code Playground

by pierian_design

JavaScript

/*let aRows1 = [
  ["1",	"2",	"3",	"4",	"5!"],
  ["1",	"2",	"3",	"4",	"5"],
  ["1",	"2",	"3",	"4",	"5!"],
  ["1",	"2",	"3",	"4!",	"5!"],
  ["1",	"2",	"3",	"4!",	"5!"],
  ["1",	"2",	"3",	"4",	"5"],
];

let aRows2 = [
  ["1",	"2",	"3",	"4",	"5"],
  ["1",	"2",	"3",	"4",	"5"],
  ["1",	"2",	"3",	"4",	"5"],
];*/

let aRows1 = [
  ["1",	"2",	"3",	"4",	"5!"],
  ["1",	"2",	"3",	"4",	"5"],
  ["1",	"2",	"3",	"4",	"5!"],
  ["1",	"2",	"3",	"4!",	"5!"],
  ["1",	"2",	"3",	"4!",	"5!"],
  ["1",	"2",	"3",	"4",	"5!!"],
];

let aRows2 = [
  ["1",	"2",	"3",	"4",	"5!"],
  ["1",	"2",	"3",	"4",	"5"],
  ["1",	"2",	"3",	"4",	"5!"],
  ["1",	"2",	"3",	"4!",	"5!"],
  ["1",	"2",	"3",	"4",	"5"],
  ["1",	"2",	"3",	"4",	"5!!"],
];

console.log('+++++++++++++++++aRows1+++++++++++++++++++');
console.log(aRows1);

console.log('+++++++++++++++++aRows2+++++++++++++++++++');
console.log(aRows2);

/*
let aRows1 = [
  ["a",	"a",	"a",	"a",	"a"],
];

let aRows2 = [
  ["w",	"w",	"w",	"w",	"w"],
  ["e",	"e",	"e",	"e",	"e"],
  ["a",	"a",	"a",	"a",	"a"],
];
*/
let getStatus = function(cellsLen) {
  let sStatus = '';

  if (cellsLen === 5) {
    sStatus = 'unique';
  } else if (cellsLen === 0) {
    sStatus = 'equal';
  } else {
    sStatus = 'different';
  }

  return sStatus;
}

let _getCellsIndexes = function (arr1, arr2) {
  var result = [], longerLength = arr1.length >= arr2.length ? arr1.length : arr2.length;
  for (i = 0; i < longerLength; i++){
    if (arr1[i] !== arr2[i]) {
      result.push(i+1);
    }
  }
  return result;
};

let oAllResults = {};
let aSkipRows = []; //переделать на equal???

for (let i = 0; i < aRows1.length; i++) {
  oAllResults[i] = [];
  let oRow1 = aRows1[i];
  let aValues1 = oRow1;

  for (let j = 0; j < aRows2.length; j++) {
    let oRow2 = aRows2[j];
    let aValues2 = oRow2;
    let aCells = _getCellsIndexes(aValues1, aValues2);
    let sStatus = getStatus(aCells.length);
    
    if (sStatus !== 'unique') {
    	oAllResults[i][j] = { index: j, cols: aCells, status: sStatus...