Your mission
In the academic system developed by Nexo, each student completes three assessments and may (or may not) have extra bonus points. To keep module functions flexible and clean, JavaScript lets you define default parameter values (cantidad = 3 or bonificacion = 0) that automatically take effect when that argument is omitted in a function call.
You must implement these five helper functions:
sumarPuntajes(a, b, c): returns a + b + c.
calcularPromedio(suma, cantidad = 3): returns Math.floor(suma / cantidad).
aplicarBonificacion(promedio, bonificacion = 0): returns Math.min(100, promedio + bonificacion).
determinarAprobacion(puntajeFinal, notaMinima): returns the boolean puntajeFinal >= notaMinima.
generarMensaje(nombre, aprobado): returns the exact Spanish string "NOMBRE ha aprobado." when aprobado is true, or "NOMBRE debe seguir practicando." when it is false (replacing NOMBRE with the original name).
Additionally, implement solve(input), which receives a JSON object with:
nombre: non-empty string of 1 to 40 characters.
puntajes: array of exactly three integers between 0 and 100.
bonificacion: optional property (when present, an integer between 0 and 20; never null).
notaMinima: integer between 0 and 100.
Coordination rules in solve(input):
- Call
sumarPuntajes with the three elements of puntajes.
- Call
calcularPromedio(sumaPuntajes) without passing the second argument, so it uses the default cantidad = 3.
- When
bonificacion is absent (undefined), call aplicarBonificacion(promedio) omitting the second argument so it uses the default bonificacion = 0; when present, pass it as the second argument. The bonus does not modify promedio.
- Call
determinarAprobacion and generarMensaje to complete the report.
Return a JSON object with those exact six properties: nombre, sumaPuntajes, promedio, puntajeFinal, aprobado, and mensaje.
Rules and constraints
- Declare and use all five helper functions with
return and local const / let variables.
- Do not mutate the
input object or the puntajes array.
- Do not use global variables,
console.log as a return mechanism, recursion, classes, advanced array methods, or asynchronous code.