Skip to content
Advertisement

if statement not working to add 1 based on a condition

This code determines the wins and losses of each quarter but I am having trouble with the PerfectQuarter. A PerfectQuarter is described as when one team has 0 points in a quarter but the other team scores.
Everything runs fine but when I enter scores for each quarter and put 00-01 for quarter one, the print statement at the end of my program prints

PerfectQuarters: 0

for both teams, although Team 2 should have a perfect quarter of 1 since in QuarterOne they scored once and Team 1 scored 0 points.

JavaScript

Advertisement

Answer

Try to divide “comparing” conditions and “check perfect” conditions in two separate if-else branches

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement