For instance, we write
const canvas = document.getElementById("theCanvas"); const parent = document.getElementById("parent"); canvas.width = parent.offsetWidth; canvas.height = parent.offsetHeight;
to select the
canvas and the
parent element with
Then we get the
offsetHeight and set them as the
height to make them the same width and height.