diff --git a/src/courseware/course/course-exit/CourseRecommendations.jsx b/src/courseware/course/course-exit/CourseRecommendations.jsx
index 112d2ea3..8d0f92ab 100644
--- a/src/courseware/course/course-exit/CourseRecommendations.jsx
+++ b/src/courseware/course/course-exit/CourseRecommendations.jsx
@@ -143,15 +143,17 @@ function CourseRecommendations({ intl, variant }) {
dispatch(fetchCourseRecommendations(courseKey, courseId));
}, [dispatch]);
+ const recommendationsLength = recommendations ? recommendations.length : 0;
+
if (recommendationsStatus && recommendationsStatus !== LOADING) {
sendTrackEvent('edx.ui.lms.course_exit.recommendations.viewed', {
course_key: courseKey,
recommendations_status: recommendationsStatus,
- recommendations_length: recommendations ? recommendations.length : 0,
+ recommendations_length: recommendationsLength,
});
}
- if (recommendationsStatus === FAILED || (recommendationsStatus === LOADED && recommendations.length < 2)) {
+ if (recommendationsStatus === FAILED || (recommendationsStatus === LOADED && recommendationsLength < 2)) {
return (