Implementing Promise.race

const promiseRace = promises => new Promise(((resolve, reject) => {
  promises.forEach(promise => {
    promise.then(res => {
      resolve(res);
    });

    promise.catch(rej => {
      reject(rej);
    });
  });
}));

Errors appear after its execution: unhandled rejection. How to solve a problem?