I wrote this code that's supposed to correct quizzes on a webpage, but it feels bloated and I'm sure there's tons of ways to improve it. Any thoughts?$ ->  #When submit_quiz div is clicked, do the following  $(document).on click, #submit_quiz, (e) ->    #Gets the quiz id for later use    qid = getQuestions(this)    #console.log qid    #Create a jquery object for the specific quiz div, select the quiz    quiz = $(#quiz_+qid)    #Setup some variables to be used later    window.qn = null    window.checked = null    wrong = []    #Select questions inside the quiz    quizchild = quiz.children() #Gets all questions like so in an object, I THINK    #Loop through the questions one at a time    for z,y in quizchild      #Iterate if id = submit_quiz      if $(z).attr('id') == 'submit_quiz'        break      #Get children of a question      question = $(z).children()      #Loop through the options      for u,i in question        #Check if the id exists, so it ignores <br>        if $(u).attr('id')?          #Set the length of our option array          window.qn = $(u).length          #The correct answer to the question, modify later          correct = null          #Get children of options, used for getting each individual options params          options = $(question).children()          #Loop the options and check if they're correct, if it's wrong, push it to a variable 'wrong' for later use          for d,i in options            child = $(d).children()[1]            if $(child).is(:checked)              window.checked+=1              if $(child).attr('id') == 'correct'                correct = $(child).attr('id')              else                $(child).css(color, red)                wrong.push $(u).attr('id')      #Check if 'wrong' has anything in it      if wrong.present()        for o,i in wrong          $('#'+o).css('color', 'red')          console.log o          console.log This quiz is wrong.. This is bad!        #If it hasn't, check if all boxes are filled, if they are, the quiz is correctly answered      else if !wrong.present() && window.checked == window.qn + 1        console.log This quiz is correctly answered yes guys!!!!        #Else, not all boxes are checked      else        console.log Not all boxes in this quiz checked!Array::present = ->  @.length > 0getQuestions = (thiss) ->  fvalue = $(thiss).attr(quiz)  return fvalueBear with me on the obsolete comments and console logs please.
Correcting a quiz
coffeescript;quiz