// 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);
- // };
const list1 = [ { firstName: "Gabriel", lastName: "X.", country: "Monaco", continent: "Europe", age: 49, language: "PHP", }, { firstName: "Odval", lastName: "Fabio.", country: "Mongolia", continent: "Asia", age: 38, language: "Python", }, { firstName: "Guea", lastName: "Serge.", country: "Italy", continent: "Europe", age: 24, language: "Java", }, { firstName: "Sou", lastName: "Bocc.", country: "Japan", continent: "Asia", age: 49, language: "PHP", }, ]; const list2 = [ { firstName: "Gabriel", lastName: "X.", country: "Monaco", continent: "Europe", age: 49, language: "PHP", }, { firstName: "Odval", lastName: "F.", country: "Mongolia", continent: "Asia", age: 38, language: "Python", }, { firstName: "Emilija", lastName: "S.", country: "Lithuania", continent: "Europe", age: 19, language: "Python", }, { firstName: "Sou", lastName: "B.", country: "Japan", continent: "Asia", age: 49, language: "PHP", }, { firstName: "Sou", lastName: "B.", country: "Japan", continent: "Asia", age: 49, language: "PHP", }, ]; console.log(findSenior(list1)); // [{ firstName: 'Gabriel', lastName: 'X.', country: 'Monaco', continent: 'Europe', age: 49, language:'PHP' }, { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' }] console.log(findSenior(list2)); // [{ firstName: 'Gabriel', lastName: 'X.', country: 'Monaco', continent: 'Europe', age: 49, language:'PHP' }, { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' }, // { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' }] // 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 list1 = [
- {
- firstName: "Gabriel",
- lastName: "X.",
- country: "Monaco",
- continent: "Europe",
- age: 49,
- language: "PHP",
- },
- {
- firstName: "Odval",
- lastName: "Fabio.",
- country: "Mongolia",
- continent: "Asia",
- age: 38,
- language: "Python",
- },
- {
- firstName: "Guea",
- lastName: "Serge.",
- country: "Italy",
- continent: "Europe",
- age: 24,
- language: "Java",
- },
- {
- firstName: "Sou",
- lastName: "Bocc.",
- country: "Japan",
- continent: "Asia",
- age: 49,
- language: "PHP",
- },
- ];
- const list2 = [
- {
- firstName: "Gabriel",
- lastName: "X.",
- country: "Monaco",
- continent: "Europe",
- age: 49,
- language: "PHP",
- },
- {
- firstName: "Odval",
- lastName: "F.",
- country: "Mongolia",
- continent: "Asia",
- age: 38,
- language: "Python",
- },
- {
- firstName: "Emilija",
- lastName: "S.",
- country: "Lithuania",
- continent: "Europe",
- age: 19,
- language: "Python",
- },
- {
- firstName: "Sou",
- lastName: "B.",
- country: "Japan",
- continent: "Asia",
- age: 49,
- language: "PHP",
- },
- {
- firstName: "Sou",
- lastName: "B.",
- country: "Japan",
- continent: "Asia",
- age: 49,
- language: "PHP",
- },
- ];
- console.log(findSenior(list1)); // [{ firstName: 'Gabriel', lastName: 'X.', country: 'Monaco', continent: 'Europe', age: 49, language:'PHP' }, { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' }]
- console.log(findSenior(list2)); // [{ firstName: 'Gabriel', lastName: 'X.', country: 'Monaco', continent: 'Europe', age: 49, language:'PHP' }, { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' },
- // { firstName: 'Sou', lastName: 'B.', country: 'Japan', continent: 'Asia', age: 49, language: 'PHP' }]
function findSenior(list) {let maxAge = 0;list.forEach((dev) => { // ho usato forEach per trovare l'età massima tra gli sviluppatoriif (dev.age > maxAge) {maxAge = dev.age;}});return list.filter((dev) => dev.age === maxAge); // ho usato filter per filtrare gli sviluppatori con l'età massima}- // 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); };
// Solutionfunction findSenior(list) {let maxAge = 0;list.forEach((dev) => { // ho usato forEach per trovare l'età massima tra gli sviluppatoriif (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);
- };
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);