goodwin64

q-n bank

Dec 9th, 2024 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 1. select columns A and G from the Google Doc with the questions (category and title)
  2.  
  3. // 2. paste into console as:
  4. var docsData = `
  5. ... text you copied
  6. `;
  7.  
  8. // 3. run the code below, copy the printed result
  9.  
  10. console.log(
  11.     docsData.split('\n')
  12.         .map(row => {
  13.             let [category, questionText] = row.split('\t');
  14.             category = category
  15.                 ?.trim()
  16.                 .replaceAll('&', 'and')
  17.                 .replaceAll(' ', '_')
  18.                 .toUpperCase();
  19.             questionText = questionText?.trim();
  20.             return questionText ? { category, questionText } : null;
  21.         })
  22.         .filter(Boolean)
  23.         .map(r => `{ questionText: \`${r.questionText}\`, category: questionCategoriesEnum.${r.category} }`)
  24.         .join(',\n')
  25. )
Advertisement
Add Comment
Please, Sign In to add comment