isaiahcannon4113 isaiahcannon4113
  • 25-11-2020
  • Computers and Technology
contestada

Write an if-else statement for the following: If user_tickets is less than 5, assign 1 to num_tickets. Else, assign user_tickets to num_tickets

Respuesta :

AbsorbingMan AbsorbingMan
  • 25-11-2020

Solution :

function tickets(user_tickets){

var num_tickets;

if (user_tickets < 5) {

num_tickets = 1;

return ('num_tickets: '+ num_tickets);

}

else {

num_tickets = user_tickets;

 return('num_tickets: '+ num_tickets);

}

}

// Testing the tickets function

// With user_tickets = 3, 5, 8, and 1

console.log(tickets(3));

console.log(tickets(5));

console.log(tickets(8));

console.log(tickets(1));

Answer Link

Otras preguntas

He designed the “City of Brotherly Love.
How to divide 457 by 4 in long division
How are the Athenian values of rule of law and citizenship expressed in modern representative democracies such as the one practiced in the United States?
how does crooks explain to lennie why he upset him?
What is 4/5 + 1/8 ? Add and simplify
Tortoise A walks 52.0 feet per hour and tortoise B walks 12 inches per minute. Which tortoise travels faster?
Twelve less than the one fifth of a number is
what is the answer to x+36=4x
how do i use Eukaryote in a sentence
If a historian wanted to determine whether iron tools can be found in the ruins of an ancient African city, which kind of expert should he consult?