I have a piece of code where I am setting the status of two scope variables based on an AND operation.
Depending on the key, I call the relevant method. The only difference between the two methods is checking prop3.
I believe the code is quite redundant and I'm unsure how to optimize it. Do you have any ideas on how I can achieve my objective with less code?
if(key =='White')
_checktests1();
else
_checktests2 ();
var _checktests1 = function () {
if ($scope.test.Prop1 == "one" && $scope.test.Prop2 == "two")
$scope.checkWhiteStatus = true;
else
$scope.checkWhiteStatus = false;
if ($scope.test.Prop1 == "three" && $scope.test.Prop2 == "four" )
$scope.checkGreenStatus = true;
else
$scope.checkGreenStatus = false;
}
var _checktests2 = function () {
if ($scope.test.Prop1 == "one" && $scope.test.Prop2 == "two" && $scope.test.Prop3 == "five")
$scope.checkWhiteStatus = true;
else
$scope.checkWhiteStatus = false;
if ($scope.test.Prop1 == "three" && $scope.test.Prop2 == "four" $scope.test.Prop6 == "six")
$scope.checkGreenStatus = true;
else
$scope.checkGreenStatus = false;
}