From dacc18440f2c13bb9c2b726613a4a5f3977d9669 Mon Sep 17 00:00:00 2001 From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de> Date: Tue, 26 Oct 2021 14:34:53 +0200 Subject: [PATCH] Edit function: format observations scatter plot Replace if/else block with ternary operator --- public/js/src_modules/chartScatterPlot.mjs | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/public/js/src_modules/chartScatterPlot.mjs b/public/js/src_modules/chartScatterPlot.mjs index ff11192..71a32d9 100644 --- a/public/js/src_modules/chartScatterPlot.mjs +++ b/public/js/src_modules/chartScatterPlot.mjs @@ -36,20 +36,18 @@ const formatSensorThingsApiResponseForScatterPlot = function ( obsArrayOne, obsArrayTwo ) { - // When our observation arrays have DIFFERENT lengths - if (obsArrayOne.length !== obsArrayTwo.length) { - const [obsArrayOneFinal, obsArrayTwoFinal] = - checkForAndDeleteUniqueObservationsFromLargerArray( - obsArrayOne, - obsArrayTwo - ); - - return createCombinedObservationValues(obsArrayOneFinal, obsArrayTwoFinal); - } - // When our observation arrays already have SAME lengths - else { - return createCombinedObservationValues(obsArrayOne, obsArrayTwo); - } + // Check if our observation arrays have equal lengths, + // remove the unique observations, if necessary + const [obsArrayOneFinal, obsArrayTwoFinal] = + obsArrayOne.length !== obsArrayTwo.length + ? checkForAndDeleteUniqueObservationsFromLargerArray( + obsArrayOne, + obsArrayTwo + ) + : [obsArrayOne, obsArrayTwo]; + + // Create the combined observations array + return createCombinedObservationValues(obsArrayOneFinal, obsArrayTwoFinal); }; /** -- GitLab