TypeError: undefined is not an object (evaluating 'answer[i].option[que.crt]') | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

TypeError: undefined is not an object (evaluating 'answer[i].option[que.crt]')

function showYourAns() { $(".ans-list").html(""); $(".sc").text(score+ "/"+ques.length) ques.forEach((que,i) => { const li = document.createElement('li'); const p = document.createElement('p'); const span = document.createElement('span'); p.textContent = 1+i +" : "+ que.que; const chrt = que.crt == answer[i] ? '👉' : '❌'; span.textContent = chrt +" "+ que.option[answer[i].option[que.crt]]; const cls = que.crt == answer[i] ? 'green' : 'red'; span.classList.add(cls); li.appendChild(p) li.appendChild(span) $(".ans-list").append(li); }) }

18th Feb 2021, 2:46 AM
Online Mining junction
Online Mining junction - avatar
1 Answer
0
Save your code in SoloLearn, and share its link in place of the raw text partial code above. Partial code is harder to debug. Here's how you can share your code link 👇 https://www.sololearn.com/post/75089/?ref=app
18th Feb 2021, 4:02 PM
Ipang