dimanche 8 novembre 2020

JS console any option from if...else

I´ve started with JS, and I cannot get print in console, one of the following options in this exercise. The selected option depends on the input of the user with a prompt, but after reviewing everything I cannot debug it, Any help please?? Thank you!!

let guests = prompt('How many people are coming to your wedding?');

function getPrice(guests) {
  let cost = 0;

  if (guests <= 50) {
     cost = 4000;
  } 
  else if (guests >= 51){
      cost = 10000;
  }
  else if (guests >= 101){
      cost = 15000;
  }
  else (guests >= 201){
      cost = 20000;
  }    
  return cost;
}
let price = getPrice();

console.log ('Your wedding will cost '+'$'+price+' dollars');

Aucun commentaire:

Enregistrer un commentaire