Repository: freeCodeCamp/freeCodeCamp
File: curriculum/get-challenges.js (JavaScript)

Code before:
// without passing around a ton of arguments.
function generateChallengeCreator(lang, englishPath, i18nPath) {
  function addMetaToChallenge(challenge, meta) {
    const challengeOrder = findIndex(
      meta.challengeOrder,
      ({ id }) => id === challenge.id
    );

    const isObjectIdFilename = /[a-z0-9]{24}\.md$/.test(englishPath);
    if (isObjectIdFilename) {
      const filename = englishPath.split('/').pop();
      if (filename !== `${challenge.id}.md`) {
        throw Error(
          `Filename ${filename} does not match challenge id ${challenge.id}`
        );
      }
    }

    challenge.block = meta.dashedName;
    challenge.blockType = meta.blockType;
    challenge.hasEditableBoundaries = !!meta.hasEditableBoundaries;
    challenge.order = meta.order;

    if (!challenge.description) challenge.description = '';
    if (!challenge.instructions) challenge.instructions = '';
    if (!challenge.seed) challenge.seed = '';

    // const superOrder = getSuperOrder(meta.superBlock);
    // NOTE: Use this version when a super block is in beta.
    const superOrder = getSuperOrder(meta.superBlock, {
      // switch this back to SHOW_NEW_CURRICULUM when we're ready to beta the JS superblock
      showNewCurriculum: process.env.SHOW_UPCOMING_CHANGES === 'true'
    });
    if (superOrder !== null) challenge.superOrder = superOrder;
    /* Since there can be more than one way to complete a certification (using the
   legacy curriculum or the new one, for instance), we need a certification
   field to track which certification this belongs to. */
    const dupeCertifications = [
      {
        certification: 'responsive-web-design',
        dupe: '2022/responsive-web-design'
      }
    ];
    const hasDupe = dupeCertifications.find(
      cert => cert.dupe === meta.superBlock
    );
    challenge.certification = hasDupe ? hasDupe.certification : meta.superBlock;
    challenge.superBlock = meta.superBlock;
    challenge.challengeOrder = challengeOrder;
    challenge.isPrivate = challenge.isPrivate || meta.isPrivate;
    challenge.required = (meta.required || []).concat(challenge.required || []);

Review comment (suggestion):
```suggestion
```
Oops. The seed is already checked for (as part of the challenge file validation).

Code after:
// without passing around a ton of arguments.
function generateChallengeCreator(lang, englishPath, i18nPath) {
  function addMetaToChallenge(challenge, meta) {
    const challengeOrder = findIndex(
      meta.challengeOrder,
      ({ id }) => id === challenge.id
    );

    const isObjectIdFilename = /[a-z0-9]{24}\.md$/.test(englishPath);
    if (isObjectIdFilename) {
      const filename = englishPath.split('/').pop();
      if (filename !== `${challenge.id}.md`) {
        throw Error(
          `Filename ${filename} does not match challenge id ${challenge.id}`
        );
      }
    }

    challenge.block = meta.dashedName;
    challenge.blockType = meta.blockType;
    challenge.hasEditableBoundaries = !!meta.hasEditableBoundaries;
    challenge.order = meta.order;

    if (!challenge.description) challenge.description = '';
    if (!challenge.instructions) challenge.instructions = '';

    // const superOrder = getSuperOrder(meta.superBlock);
    // NOTE: Use this version when a super block is in beta.
    const superOrder = getSuperOrder(meta.superBlock, {
      // switch this back to SHOW_NEW_CURRICULUM when we're ready to beta the JS superblock
      showNewCurriculum: process.env.SHOW_UPCOMING_CHANGES === 'true'
    });
    if (superOrder !== null) challenge.superOrder = superOrder;
    /* Since there can be more than one way to complete a certification (using the
   legacy curriculum or the new one, for instance), we need a certification
   field to track which certification this belongs to. */
    const dupeCertifications = [
      {
        certification: 'responsive-web-design',
        dupe: '2022/responsive-web-design'
      }
    ];
    const hasDupe = dupeCertifications.find(
      cert => cert.dupe === meta.superBlock
    );
    challenge.certification = hasDupe ? hasDupe.certification : meta.superBlock;
    challenge.superBlock = meta.superBlock;
    challenge.challengeOrder = challengeOrder;
    challenge.isPrivate = challenge.isPrivate || meta.isPrivate;
    challenge.required = (meta.required || []).concat(challenge.required || []);
    challenge.template = meta.template;