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

Embed on website

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