88.5k views
1 vote
Write an if-else statement in Javascript that if userTickets is less than 5, executes awardPoints = 20. Else, execute awardPoints = userTickets. Ex: If userTickets is 3, then awardPoints = 20.

User Gunnx
by
4.9k points

1 Answer

6 votes

Answer:

if (userTickets < 5) {

awardPoints = 20;

}

else {

awardPoints = userTickets;

}

Step-by-step explanation:

To write an if-else statement in Javascript, you must include a condition (in the "if" section) and an action that takes place. So this statement tests if userTickets is less than 5 and, if it is, it sets the awardPoints variable to equal 20. If it's not, then it sets the awardPoints variable to equal the userTickets amount.

User Latoya
by
5.7k points