-4
I was able to solve this question more I wanted to know if I can simplify it because I am in the middle of learning and I look for different ways to do the same thing to be able to fix it well in the mind. the question is as follows.
A parking lot wants to automate the collection of monthly messages.
If the driver held up to 20 entries, he must pay $ 10,00 per admission held.
From the twenty-first entry onwards, each entry costs R $ 5,00 to the customer.
//array que recebe as placas dos veiculos
var placas = [
    'RXB-2525', 'AKX-3333', 'ORO-7142','RXB-2525', 'AKX-3333', 'ORO-7142',
    'AKX-3333', 'RXB-2525', 'AKX-3333','AKX-3333', 'RXB-2525', 'AKX-3333', 
    'RXB-2525', 'AKX-3333', 'ORO-7142','AKX-3333', 'AKX-3333', 'RXB-2525',
    'AKX-3333', 'ORO-7142', 'ORO-7142','AKX-3333', 'AKX-3333', 'RXB-2525',
    'AKX-3333', 'AKX-3333', 'RXB-2525','AKX-3333', 'AKX-3333', 'RXB-2525',
    'AKX-3333', 'ORO-7142', 'ORO-7142','AKX-3333', 'ORO-7142', 'ORO-7142',
    'ORO-7142', 'RXB-2525', 'AKX-3333','AKX-3333', 'ORO-7142', 'ORO-7142',
    'AKX-3333', 'RXB-2525', 'AKX-3333','AKX-3333', 'RXB-2525', 'AKX-3333',
    'RXB-2525', 'AKX-3333', 'ORO-7142','AKX-3333', 'AKX-3333', 'RXB-2525',
    'AKX-3333', 'ORO-7142', 'ORO-7142','AKX-3333', 'AKX-3333', 'RXB-2525',
    'AKX-3333', 'AKX-3333', 'RXB-2525','AKX-3333', 'AKX-3333', 'RXB-2525'
 ]
 
//aqui calcula quantas vezes essa mesma placa entrou no estacionamento
 function calcularNumeroDeEntradas(placa){
    var entradas = 0
    for(var i = 0;i < placas.length; i++) {
       if (placas[i] == placa){
           entradas++
       }
    }
    return entradas
 }
//aqui calcula o valor que o dono do carro deve pagar, E aqui que queria simplificar o código
 function calcularValorDevido(placa){
   var valorDevido = calcularNumeroDeEntradas(placa)
    if (valorDevido < 21){
       return valorDevido = valorDevido*10
    } else{
       return valorDevido = ((valorDevido-20)*5) + (20*10)
    }
}
 console.log(calcularNumeroDeEntradas("ORO-7142"))
 console.log(calcularValorDevido("ORO-7142"))
I think I put myself wrong on the simple question, but it was that same other ways to do the same thing, helped me a lot has things I need to go deeper, and the way you answered showed me another way to solve the problem and even more beautiful to see kkkk XD.
– alexandre