function weightFn (list, count) { if (!list || !list.length || !count) return false; let sum = list.reduce((pre, cur) => pre+=cur, 0); if (sum % count === 0) return true; return false; } let list = [2,2,3,3,5]; // let list = [3,5,5,6,7]; let count = 3; const result = weightFn(list, count); console.log(result)