logo
logo

Resize Logger

Resize Logger

Easy
Create a function called
resizeLogger
that logs the dimensions of the window whenever it is resized. The function should add an event listener to the window object for the
resize
event and call the
handleResize
function whenever the event is triggered.
The
handleResize
function should log the dimensions of the window using the
console.log
method, in the format:
Window dimensions: <width> x <height>
, where
<width>
and
<height>
are replaced with the actual dimensions of the window.
The
resizeLogger
function should return a cleanup function that removes the
resize
event listener from the window object when called.

Example usage:

const cleanup = resizeLogger();

// Output:
// Window dimensions: 1920 x 1080
// Window dimensions: 1280 x 720

Console
Submit
Solution
00:00