Classify a player's level by effective experience ranges using if/else and assign membership benefits using switch/case.
JavaScriptBeginnerWith Nexo
condicionales · switch · rangos-numericos
Statement
Your mission
In JavaScript, if / else if / else is ideal for evaluating numeric ranges and boolean conditions, whereas switch is very clear when comparing a single value against exact discrete cases (such as a player's membership tier).
Implement the solve(input) function, which receives a JSON object with four properties:
experiencia: integer between 0 and 10000.
tipoJugador: exactly "NORMAL", "PREMIUM", or "VIP".
tienePenalizacion: boolean.
eventoEspecial: boolean.
Apply the following rules in order:
Calculate experienciaEfectiva (using if):
Start with experiencia.
If eventoEspecial is true, add 500.
If tienePenalizacion is true, subtract 300.
Both modifiers are cumulative, and if the result is less than 0, clamp experienciaEfectiva to 0.
Classify by experienciaEfectiva ranges (using if, else if, else):
0 to 999: nivel = 1, nombreNivel = "NOVATO"
1000 to 2499: nivel = 2, nombreNivel = "APRENDIZ"
2500 to 4999: nivel = 3, nombreNivel = "EXPLORADOR"
5000 to 7499: nivel = 4, nombreNivel = "EXPERTO"
7500 or more: nivel = 5, nombreNivel = "MAESTRO"
Benefits by tipoJugador (using switch, case, break, and default):
recompensa = nivel * 100 * multiplicadorRecompensa.
Return a JSON object with those exact seven properties: experienciaEfectiva, nivel, nombreNivel, tipoJugador, multiplicadorRecompensa, recompensa, and contenidoExclusivo.
Rules and constraints
Use if / else if / else for the modifiers, minimum zero floor, and range classification, and switch (with break in every case plus default) for tipoJugador.
Do not use ternary operators (? :), configuration objects, maps, arrays, loops, classes, or helper functions.
tipoJugador never modifies experience or level; it only defines multiplicadorRecompensa and contenidoExclusivo.