Just like your original assignment, you shouldn't use ()
. Use:
window.onresize = onResizeWindow;
// and
window.onresize = onResizeWindow2;
Adding the ()
immediately calls the functions and assigns their return value to the onresize
property. These functions return nothing, so undefined
is the returned value, meaning nothing runs when the window is resized.