Skip to content

Enhancement - Any interest in a helper function to show exercise by number? #176

@seanpoulter

Description

@seanpoulter

I've noticed that it takes a bit of fiddling to reproduce issues on specific exercises. Would you accept a PR that adds a showLessonByNumber function like:

/**
 * @param {number} n  The lesson number starting from 1
 */
function showLessonByNumber(n) {
  var item = $(".lesson").get(n - 1);
  if (item) {
    showLesson(item);
  } else {
    throw new Error("Exercise " + (n - 1) + " could not be found.");
  }
}

Since this would be the third spot we're changing the visibility of a lesson, I'd suggest we extract that function as showLesson:

/**
 * @param {Element} lessonElement
 */
function showLesson(lessonElement) {
  var post = $(".post", lessonElement)[0];
  lessonElement.style.visibility = "visible";

  if (post !== undefined) { 
    post.style.visibility = "visible"; 
  } 
}

We could call this function in these two spots as well:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions