function calcularTarifaEstacionamiento(tipoVehiculo: string, horas : number): string{
    let costoPrimeraHora : number = 0;
 switch(tipoVehiculo){
     case 'moto': 
         costoPrimeraHora = 20;
         break;
     case 'auto': 
         costoPrimeraHora = 40;
         break;
     case 'camioneta': 
         costoPrimeraHora = 60;
         break;
     default:
         return "Vehiculo no autorizado";
 }
         let costoTotal : number = costoPrimeraHora;
         if(horas > 1){
             costoTotal= costoTotal + (horas-1) *15;
             }
         if (horas > 8){
             costoTotal= costoTotal + 50;
 }
return "Ticket de estacionamiento para" + tipoVehiculo + "Total a pagar por" + horas + " horas: $" + costoTotal + "pesos";
         
  
}
console.log(calcularTarifaEstacionamiento( "CAMIONETA",2));

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: