JSFiddle - React, Tailwind, and code Playground

by Abdul Ahmad

JavaScript

function getRadioParameters(influence, relevance, motivation, orientation) {
  const inf = gague(influence, 'HIGH-influence', 'LOW-influence');
  const rel = gague(relevance, 'HIGH-relevance', 'LOW-relevance');
  const mot = gague(motivation, 'HIGH-motivation', 'LOW-motivation');
  const ori = gague(orientation, 'HIGH-orientation', 'LOW-orientation');
  const allVals = [inf, rel, mot, ori];
  const finalValue = allVals.reduce(getFinalValues);

  return finalValue;
}

function getFinalValues(prev, next) {
  const prevImg = prev.img || '';  
  const prevChar = prev.char || '';
  const img = prevImg + next.img;
  const char = prevChar + ' ' + next.char;
  return { img, char };
}

function gague(param, high, low) {
  if (param >= 3) return { char: high, img: 'H' };
  return { char: low, img: 'L' };
}

let result = getRadioParameters(3, 3, 3, 3);
console.log(result);

result = getRadioParameters(3, 3, 3, 0);
console.log(result);

result = getRadioParameters(3, 3, 0, 3);
console.log(result);

result = getRadioParameters(3, 0, 3, 3);
console.log(result);