The elements that you want to update are $(".box-1") and $(".box-2"). Instead of update them, you took theirs height value, and tried to update their height value's height value (something like that: $(".box-1").height().height(new_value);, which obviously doesn't exist. The compare was good, but the update wasn't for the right elements.
Instead of taking $('.box-1').height();, you can take only the element $('.box-1') and work with it.
Like this:
var box1 = $('.box-1');
var box2 = $('.box-2');
Now that we have the element itself, let's work with it's attributes. To get the height of the element- use:
box1.height();
To set new value to this height property, use:
box1.height(new_value);
Put it all together:
var box1 = $('.box-1');
var box2 = $('.box-2');
if (box1.height() > box2.height()) {
    box1.height(box2.height())
} else {
    box2.height(box1.height())
}