Inserting a semicolon in a string
ClarenceS12Chew 18 Mar 2012 01:42
This is the JavaScript code for a quiz. The problem is that there are semicolons in the strings.
function quizmaker(questions,quizname) { var questionnumber=1; var javascriptcode="function "+quizname+"() { \n"; javascriptcode+="var ans=\"@@\"\n"; while(questionnumber<questions+1) { javascriptcode+="while (ans!="; while(rightans!="@@") { rightans=prompt("Type out the answer for question 1."); } javascriptcode+=rightans+") {\n"; javascriptcode+="ans=\"@@\";\n"; // Answer is recommended to be an integer. javascriptcode+="alert("+questionnumber+". "; thequestion=prompt("Input the question."); // Question is recommended to be a multiple-choice question or a math question. javascriptcode+=thequestion+"\");\n"; javascriptcode+="ans=prompt(\"Type in your answer.\");\n"; javascriptcode+="}\n"; questionnumber++; } javascriptcode+="alert(\"Congratulations! You have finished the quiz!\");\n"; javascriptcode+="}"; return javascriptcode; }
Please help if you know how to.
Does \u003b work to replace semicolon?