Skip to content

Commit

Permalink
Update code.js
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticalMike60t committed May 16, 2024
1 parent cd8f83a commit 0b37669
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions code.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@
if (contentDiv) {
questions.forEach((question, index) => {
const questionDiv = document.createElement("div");
questionDiv.className = "answer";
questionDiv.textContent = `Question: ${question.key}`;
contentDiv.appendChild(questionDiv);

const responseDiv = document.createElement("div");
responseDiv.className = "answer";
responseDiv.textContent = `Response: ${responses[index]}`;
contentDiv.appendChild(responseDiv);

const separator = document.createElement("hr");
const separator = document.createElement("br");
separator.className = "answer";
contentDiv.appendChild(separator);
contentDiv.appendChild(separator);
});
} else {
Expand All @@ -68,9 +72,11 @@
responseData.length > 0 &&
typeof responseData[0] === "object"
) {
// Extract relevant information from each object and concatenate into a string
const responseText = responseData.map((obj) => obj.text).join(", ");
responses.push(responseText);
// Display each response separately
responseData.forEach((obj) => {
const responseText = obj.text;
responses.push(responseText);
});
} else {
console.error(
`Invalid response data format for question ${questionId}`
Expand Down

0 comments on commit 0b37669

Please sign in to comment.