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

a⁴+b⁴=a²b² ,prove that a⁶+b⁶=0
Would there be a problem or a major event in a horror story?
What are the advantages and disadvantages of DNA foresics/analysis?
Find the total price including 7percent tax on a $9.79 purchase
What role do media, such as virtual worlds, play in shaping gender stereotypes?
how will you discribe the sequence of oxygen ,carbon dioxide, and blood flow in your own words
The time t required to drive a certain distance varies inversely with the speed r. If it takes 2 hours to drive the distance at 40 miles per hour, how long will
At 10a.m. Juan leaves the city traveling north at 60 mi/hr. One hour later mel leaves the city traveling south at 50 mi/hr. At what time will they be 830 miles
True or false the origin would be included in the solution set for the following inequality: y>3x-9
what recent world issues/problems can be solved if people rocognize and perform their role effectively