var colorDefault = [100, 100, 100];
var colorSet = [189, 199, 165];
function compareArrays(element, index) {
return element === colorSet[index];
};
function changeRGB() {
if (colorDefault.length == colorSet.length && colorDefault.every(compareArrays)) {
clearInterval(timer);
console.log('stop')
} else {
colorDefault[0]++;
colorDefault[1]++;
colorDefault[2]++;
console.log(colorDefault);
};
};
var timer = setInterval(changeRGB, 100);
var array1 = [22, 25, 30];
var array2 = [2, 5, 10];
var n1 = array1[0], n2 = array1[1], n3 = array1[2];
var n4 = array2[0], n5 = array2[1], n6 = array2[2];
while(true) {
if(n4 !== n1) n4++;
if(n5 !== n2) n5++;
if(n6 !== n3) n6++;
console.log(n4, n5, n6);
if((n4+n5+n6) === (n1+n2+n3)) break;
}