-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
30 lines (25 loc) · 905 Bytes
/
main.js
File metadata and controls
30 lines (25 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Variáveis
let nome = "Eric, o Dev";
let xp = 17080;
let nivel = "";
// Estrutura com os níveis definidos estritamente conforme o desafio
let niveis = [
{ nome: "Ferro", min: 0, max: 1000 },
{ nome: "Bronze", min: 1001, max: 2000 },
{ nome: "Prata", min: 2001, max: 5000 },
{ nome: "Ouro", min: 5001, max: 7000 },
{ nome: "Platina", min: 7001, max: 8000 },
{ nome: "Ascendente", min: 8001, max: 9000 },
{ nome: "Imortal", min: 9001, max: 10000 },
{ nome: "Radiante", min: 10001, max: Infinity }
];
// Laço de repetição para determinar o nível com base no XP
for (let i = 0; i < niveis.length; i++) {
let faixa = niveis[i];
if (xp >= faixa.min && xp <= faixa.max) {
nivel = faixa.nome;
break;
}
}
// Saída final
console.log("O Herói de nome " + nome + " está no nível de " + nivel);