$(
function() {
function recalculateAll() {
let res = parseInt($('#myselect_1').val())
+ parseInt($('#myselect_2').val());
$('#outSumOption').text(res);
if ($('#chk1').prop('checked')) {
res *= 2;
}
$('#outSumChk1').text(res);
if ($('#chk2').prop('checked')) {
res += 100;
}
$('#outSumChk2').text(res);
$('#outSum').text(res);
}
$('select, input[type="checkbox"]').change(
function() {
recalculateAll();
}
);
recalculateAll();
}
);
let result = users.reduce(
(acc, val) => {
acc[val.id] = {
id: val.id,
first_name: val.first_name,
page_views: 0,
clicks: 0
};
return acc;
},
[]
);
result = views.reduce(
(acc, val) => {
acc[val.user_id].page_views += val.page_views;
acc[val.user_id].clicks += val.clicks;
return acc;
},
result
);
result = result.filter(x => x);