This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user