This commit is contained in:
Philippe Torrel
2026-09-28 09:42:41 +02:00
parent 8a2d979830
commit 80296c10d0
6 changed files with 89 additions and 16 deletions
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -41,17 +41,42 @@
['Dratini', 'Dragonair', 'Dragonite'],
];
const stagesFor = (pokemon) => {};
const stagesFor = (pokemon) => {
const stages = evolutionStages.find((stages) => stages.includes(pokemon));
return stages ? stages : [];
};
const stagesAfter = (pokemon) => {};
const stagesAfter = (pokemon) => {
const stages = stagesFor(pokemon);
const index = stages.indexOf(pokemon);
const stagesBefore = (pokemon) => {};
// wenn nicht gefunden
if (index === -1) return [];
return stages.slice(index + 1);
};
const stagesBefore = (pokemon) => {
const stages = stagesFor(pokemon);
const index = stages.indexOf(pokemon);
// wenn nicht gefunden
if (index === -1) return [];
return stages.slice(0, index);
};
console.log(stagesFor('Bulbasaur')); // => undefined
console.log(stagesFor('Vulpix')); // => [ 'Vulpix', 'Ninetales' ]
console.log(stagesAfter('Dratini')); // => [ 'Dragonair', 'Dragonite' ]
console.log(stagesAfter('Bulbasaur')); // => undefined
console.log(stagesAfter('Dragonite')); // => []
console.log(stagesBefore('Pidgeot')); // => [ 'Pidgey', 'Pidgeotto' ]
console.log(stagesBefore('Dragonair')); // => [ 'Dratini' ]
console.log(stagesBefore('Pidgey')); // => [ ]
console.log(stagesBefore('Pidgey')); // => []
console.log(stagesBefore('Pidgeot')); // => ['Pidgey', 'Pidgeotto']
</script>
</body>