- Given an array of outcomes.
- Given an array of responses to a survey on importance and satisfaction ratings for each of the outcomes.
- Given the response ratings are 1-5.
- IMP = 10 x % Very or Extremely important
- SAT = 10 x % Very or Extremely satisfied
- OPP = IMP + MAX (IMP-SAT, 0)
- Values of 4 or 5 are considered Very or Extremely important / satisfied
- For each outcome, create two arrays:
- Importance Rating Array
- Satisfaction Rating Array
-
Insert the corresponding response ratings into these arrays.
-
Compute aggregate values as 10 x % Very or Extremely satisfied (rating of 4 or 5) within the arrays
-
Use these aggregate values to compute opportunity score - OPP = IMP + MAX (IMP-SAT, 0)
outcomes.forEach(outcome => {
// create arrays
outcome.importanceArray = []
outcome.satisfactionArray = []
this.responses.forEach(response => {
// get data from response
imp = response[outcome.questionkey+'_a1']
sat = response[outcome.questionkey+'_a2']
// insert data into arrays
outcome.importanceArray.push(imp)
outcome.satisfactionArray.push(sat)
})
// Calculate the aggregate importance for each outcome
// IMP = 10 x % Very or Extremely important
outcome.importance = computeAggregate(outcome.importanceArray)
// Calculate the aggregate satisfaction for each outcome
// SAT = 10 x % Very or Extremely satisfied
outcome.satisfaction = computeAggregate(outcome.satisfactionArray)
// OPP = IMP + MAX (IMP-SAT, 0)
outcome.opportunity = outcome.importance + Math.max((outcome.importance - outcome.satisfaction), 0)
}
// compute aggregate values from array - 10 x % Very or Extremely satisfied
function computeAggregate(arr) {
var sum = 0;
var i = 0;
for(i; i < arr.length; i++ ) {
// values of 4 or 5 are considered Very or Extremely important
if( arr[i] > 3) { sum++ }
}
var percentVery = sum/arr.length
return percentVery * 10
}