function wisdomOfLife(experiences) {
let wisdom = [];
experiences.forEach(experience => {
if (experience.isValuable) {
wisdom.push(experience);
}
});
return wisdom;
}
function learnFromMistakes(mistakes) {
let lessons = [];
mistakes.forEach(mistake => {
let lesson = analyzeMistake(mistake);
lessons.push(lesson);
});
return lessons;
}
function journeyToWisdom(person) {
let experiences = person.experiences;
let mistakes = person.mistakes;
let wisdom = wisdomOfLife(experiences);
let lessons = learnFromMistakes(mistakes);
return wisdom.concat(lessons);
}