Reputation: 5758
There might be a very basic thing that might be missing. Please let me know if there is a better way to do this which is much more elegant than using the ternary operator in javascript.
if (data.isYellowCupcake === YES) {
dataCopy.isCupcake = true;
} else if (data.isYellowCupcake === NO) {
dataCopy.isCupcake = false;
}
Upvotes: 0
Views: 70
Reputation: 2850
Even though you said you don't want ternary operator I will leave this here.
dataCopy.isCupcake = data.isYellowCupcake === 'YES' ? true
: data.isYellowCupcake === 'NO' ? false
: null;
Upvotes: 2
Reputation: 2627
How about:
dataCopy.isCupkake = data.isYellowCupkake === YES;
By the way, the word cupcake only has one k
.
Upvotes: 3