NGHS JavaScript bugs

Bugs figured out!

Thanks

This sounds very much like an interview exercise…

To get started, try looking in your browser’s console. However, if you are applying for a job involving JavaScript and I have to tell you that, then maybe you want to rethink your career choices.

2 Likes

Hi siphavong91 - EDIT andsip8 - welcome to the forum

You will need to look at the HTML and CSS code too, but I guess the logical place to start is with the JavaScript

var itemHeader = $("accordion *:header"),
  itemHeaderClass = "accordion-item-header",
  itemWrapperHTML = "<div class='accordion-item'/>",
  itemContentClass = "accordion-content",
  itemContentHTML = "<div class='" + itemContentClass + "'></div>",
  itemControlClass = "accordion-control",
  itemControlContent = "View",
  itemControlHTML = "<div class='" + itemControlClass + "'>" + itemControlContent + "</div>";

$(itemHeader).each(
  function() {
    $(this).addClass(itemHeaderClass);
    $(this).nextUntil(itemHeader).andSelf().wrapAll(itemWrapperHTML).wrapAll("<div class='inner'/>");
    $(this).nextUntil(itemHeader).wrapAll(itemContentHTML);
  });

$(itemContentClass).each(
  function() {
    $(this).parent().prepend(itemControlHTML);
    $(this).parent().addClass("content");
  });

$(itemControlClass).click(function() {
  $(this).parents().eq(1).toggleClass("active");
});

What part(s) do you not understand?

It would helpful if you posted your solution so that others having the same problem with the NGHS recruitment question could learn from your experience.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.