I can't understand- He assigned value to a varaible.The value is geeting from the find method . He checked 2 conditions .one for selected length and one for image length.Explain please.Thankyou

I can't understand- He assigned value to a varaible.The value is geeting from the find method . He checked 2 conditions .one for selected length and one for image length.Explain please.Thankyou

 $('#image-selections .image-selection-row').each(function(index, selection_row){
   
    var row_index = $(this).data('select-index');
   
    var $selected = $(selection_row).find('.image-select.image-selected');
   
    if( $selected.length ){
   
    var $light_img = $('#image-bar-container img.img-flash[data-img-index="'+row_index+'"]');
   
    if( $light_img.length ){
   
    $light_img.attr('src', 'folder/im-' + $selected.data('pixel') + '.png' ).addClass('light-active');
   
    }
   
   
    }
   
    });