function getQuestionUrls(references) {
const urls = [];
for (let i = 0; i < references.length; i++) {
for (let j = 0; j < references[i].sections.length; j++) {
urls.push(`/groups/${references[i].groupId}/forms/${references[i].id}/sections/${references[i].sections[j].name}`)
}
}
return urls;
}
function getQuestionUrls(references) {
return references.reduce(toFlatList, []).map(toUrl);
function toFlatList(newRefs, ref) {
return [...newRefs, ...flattenSectionsWithGroup(ref)];
}
function flattenSectionsWithGroup(ref) {
return ref.sections.map((section) => ({groupId: ref.groupId, formId: ref.id, sectionName: section.name}));
}
function toUrl(urlObj) {
return `/groups/${urlObj.groupId}/forms/${urlObj.formId}/sections/${encodeURIComponent(urlObj.sectionName)}`;
}
}