The DOM provides methods for getting and setting attributes of elements. getAttribute and setAttribute allow you to read and modify attributes dynamically.
// Select the first element with class 'highlight'
let link = document.querySelector('.highlight');
// Get the 'href' attribute of a link
let linkHref = link.getAttribute('href');
// Get a reference to the element with the id 'pageTitle'
let image = document.getElementById(“image');
// Set the 'alt' attribute of an image
image.setAttribute('alt', 'New Alt Text');