when using a jQuery object multiple times (as is the case here for $(entry)), it is preferable to extract the jQuery object as a variable first (prefixing the variable name with a $ to indicate it is a jQuery object), and then reuse that variable in later calls eg:
Expected:
const $entry = $(e.target);
const courseId = $entry.data('courseid');
const studentEmail = $entry.data('studentemail');
const googleId = $entry.data('googleid');
The main difference between declaring entry = e.target, followed by using $(entry) later, and declaring $entry = $(e.target) and reusing $entry would be efficiency (no need to create the same object multiple times in the latter case).
Can I take this?
@AlexM9200 I think this is a d.FirstTimer issue. Let's wait for the confirmation from any of our @TEAMMATES/seniordevs
This is the same thing in teammates/src/main/webapp/dev/js/main/instructorFeedbackResultsQuestion.es6.
Should I fix it in this pull request or create a new issue?
const panelHeading = $(this);
if ($('#show-stats-checkbox').is(':checked')) {
$(panelHeading).find('[id^="showStats-"]').val('on');
} else {
$(panelHeading).find('[id^="showStats-"]').val('off');
}
const displayIcon = $(this).find('.display-icon');
const formObject = $(this).children('form');
const panelCollapse = $(this).parent().children('.panel-collapse');
The scope of this issue can be widened and similar violations can be fixed in the same PR.
Most helpful comment
The scope of this issue can be widened and similar violations can be fixed in the same PR.