Advertisement
-Annie-

TemplateFormat

May 30th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function format(input) {
  2.     let str = '<?xml version="1.0" encoding="UTF-8"?>\n<quiz>\n';
  3.     let questions = '';
  4.     let answers='';
  5.  
  6.     for(let i = 0; i <= input.length - 1; i+=2) {
  7.         let question = input[i];
  8.         let answer = input[i+1];
  9.         str += ` <question>\n${question}\n</question>\n`;
  10.         str += ` <answer>\n${answer}\n</answer>\n`;
  11.     }
  12.  
  13.     str += '</quiz>';
  14.     console.log(str);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement