oldest = []
                  
                  
                      let maxAge = 0
                  
                  
                      for (const person of people) {
                  
                  
                          if (person.age > maxAge) {
                  
                  
                              oldest = [person]
                  
                  
                                            maxAge = person.age
                  
                  
                          } else if (person.age == maxAge) {
                  
                  
                            oldest.push(person)
                  
                  
                           }
                  
                  
                      }
                  
                  
                      return oldest.length == 1 ? oldest[0] : oldest
                  
                  
                  }
                  
                  
                  Как то так, отформатировать и проверить нет возможности
                  
                  
                
Ваш код быстрее от 10 до 1.5 раза на моем пк)
Обсуждают сегодня