Given an object containing the number of positive and negative reviews, for example { positive: 24, negative: 8 }, return the review positivity score.
function getReviewPositivityScore (positive, negative) {
let a = positive;
let b = negative;
let result = a - b ;
return result;
}
module.exports = getReviewPositivityScore;
Error message I get: getReviewPositivityScore 1) should return the number of positive reviews minus the number of negative reviews
0 passing (6ms) 1 failing
getReviewPositivityScore should return the number of positive reviews minus the number of negative reviews:
AssertionError: expected NaN to deeply equal 16
- expected - actual
-NaN 16
at Context. (.guides/secure/test3.5.1.js:8:17) at processImmediate (internal/timers.js:439:21)
CodePudding user response:
Since you are passing an object you only need one parameter as function input, and then access the values from it:
function getReviewPositivityScore (object) {
return object.positive - object.negative;
}
CodePudding user response:
Thanks for the quick help. I was able to solve it.