const arr= [
["google.com|toster.ru|RU|120|222"],
["google.com|toster.ru|RU|120|222"],
["google.com|toster.ru|UA|120|222"],
["google.com|toster.ru|BG|120|222"],
["google.com|yandex.ru|IT|777|843"]
];
const groupBy = 2;
const filtered = Array.from(new Set(arr.map(arr => arr[0])))
.map(str => str.split('|'))
.reduce((acc, curArr) => {
const index = acc.findIndex(curAcc => {
return !curAcc.some((curAccEl, i) => curAccEl !== curArr[i] && i !== groupBy);
});
if (index === -1) {
acc.push(curArr);
}
else {
acc[index][groupBy] += '+' + curArr[groupBy];
}
return acc;
}, [])
.map(arr => [arr.join('|')]);
function diffCats(arr1, arr2) {
return arr1.filter(obj1 => {
return !arr2.some(obj2 => obj1.Category === obj2.Category && obj1.Value === obj2.Value);
});
}
const arrUniq1 = diffCats(arrFirst, arrSecond);
const arrUniq2 = diffCats(arrSecond, arrFirst);
Array.from(document.querySelectorAll('#reverse > div'))
.slice(1)
.sort((a, b) => parseInt(b.textContent) - parseInt(a.textContent))
.forEach(el => el.parentElement.appendChild(el));
class Increment {
constructor() {
this.count = 1;
}
valueOf() {
return this.count++;
}
}
function Increment() {
this.count = 1;
}
Increment.prototype.valueOf = function() {
return this.count++;
}
item.onclick = function () {
answers.forEach(el => el.classList.remove('question-item__text_active'));
icons.forEach(el => el.classList.remove('question-item__icon_active'));
answers[i].classList.add('question-item__text_active');
icons[i].classList.add('question-item__icon_active');
};
color: rgb(37.916666666666664, 216.5, 16.583333333333332) /* не работает в Safari */
const toStr = ({r, g, b}) => `rgb(${parseInt(r)}, ${parseInt(g)}, ${parseInt(b)})`;