Some comments on the Armando Pérez exercise


#1

I am talking about the following exercise:

https://www.codecademy.com/courses/jquery-ext/projects/jquery-prj_armando-perez

There are some instances in the text descriptions where it says "Armando Peréz" with the acute accent on the second "e". In Spanish orthography that would be unnecessary to mark stress on the final syllable, and the stress really goes on the first syllable. It should be "Pérez" in all cases.

More importantly, I don't understand why we are asked to do a lengthy if/else block to solve this when one if statement will do—and, even then, it is arguably unnecessary. Like so:

let main = function() {
  $('.nav li').click(function() {
    let category = $(this).attr('class').split('-')[1];
    
    $('a.thumbnail').removeClass('selected');
    
    if (category !== 'all') {
    	$(`a.${category}`).addClass('selected');
    }

    $('.nav li').removeClass('active');
    $(this).addClass('active');
  });
};
 
$(document).ready(main);

#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.