Atribut data terdekat JavaScript

const schoolInfo = [
  { id: '1' }
];

const school = document.querySelector('button');
const popUpInfo = schoolInfo.find(
  (x) => x.id == school.closest('[data-idschool]').dataset.idschool
);
console.log(popUpInfo);
EnzoK