mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-02 06:04:06 -05:00
22 lines
825 B
JavaScript
22 lines
825 B
JavaScript
import { flatten } from 'lodash';
|
|
|
|
// TODO: keeping curriculum in memory is handy if we want to field requests that
|
|
// need to 'query' the curriculum, but if we force the client to handle
|
|
// redirectToCurrentChallenge and, instead, only report the current challenge id
|
|
// via the user object, then we should *not* store this so it can be garbage
|
|
// collected.
|
|
|
|
// eslint-disable-next-line import/no-unresolved
|
|
import curriculum from '../../../../shared/config/curriculum.json';
|
|
|
|
export function getChallenges() {
|
|
return Object.keys(curriculum)
|
|
.map(key => curriculum[key].blocks)
|
|
.reduce((challengeArray, superBlock) => {
|
|
const challengesForBlock = Object.keys(superBlock).map(
|
|
key => superBlock[key].challenges
|
|
);
|
|
return [...challengeArray, ...flatten(challengesForBlock)];
|
|
}, []);
|
|
}
|