Ad
Code
Diff
  • // const findSenior = (list) => {
    //   const maxAge = Math.max(...list.map(dev => dev.age));
    //   return list.filter(dev => dev.age === maxAge);
    // };
    
    • const findSenior = (list) => {
    • const maxAge = Math.max(...list.map(dev => dev.age));
    • return list.filter(dev => dev.age === maxAge);
    • };
    • // const findSenior = (list) => {
    • // const maxAge = Math.max(...list.map(dev => dev.age));
    • // return list.filter(dev => dev.age === maxAge);
    • // };
Code
Diff
  • const findSenior = (list) => {
      const maxAge = Math.max(...list.map(dev => dev.age));
      return list.filter(dev => dev.age === maxAge);
    };
    
    • // Solution
    • function findSenior(list) {
    • let maxAge = 0;
    • list.forEach((dev) => { // ho usato forEach per trovare l'età massima tra gli sviluppatori
    • if (dev.age > maxAge) {
    • maxAge = dev.age;
    • }
    • });
    • return list.filter((dev) => dev.age === maxAge); // ho usato filter per filtrare gli sviluppatori con l'età massima
    • }
    • const findSenior = (list) => {
    • const maxAge = Math.max(...list.map(dev => dev.age));
    • return list.filter(dev => dev.age === maxAge);
    • };
Code
Diff
  • const sumNechet = (start, end) => [...Array(Math.floor((end - start) / 2) + 1)].reduce((acc, _, idx) => acc + start + 2 * idx + (start % 2 === 0 ? 1 : 0), 0);
    
    • //Крюков Кирилл
    • function sumNechet(a, b) {
    • var answer = 0;
    • for (var i = a; i <= b; i++){
    • if (i % 2 != 0){
    • answer += i;
    • }
    • }
    • return answer;
    • }
    • console.log(sumNechet(5,15));
    • const sumNechet = (start, end) => [...Array(Math.floor((end - start) / 2) + 1)].reduce((acc, _, idx) => acc + start + 2 * idx + (start % 2 === 0 ? 1 : 0), 0);