The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.

Comments

If needed, you can add comments to a program. Comments are used to explain programs. They help us humans to understand programs. Computers ignore comments.

In JavaScript there are two ways to write comments: Line comments are introduced with // and are valid until the end of the line. Block comments start with /* and end with */. Any text in between is a comment.
// That's a line comment.

// This line comment
// covers 2 lines.

/* That's a block comment. */

/* This block comment
covers 2 lines. */

/**
 * This is also a block comment.
 * The additional stars between
 * the beginning and the end of the
 * block comment are only for decoration.
 */
Block comments are often used to explain functions. Line comments explain the code flow.
/**
 * Checks whether a string contains
 * any characters other than spaces.
 */
function isBlank(string) {
  // The method trim() removes spaces at
  // the beginning and the end of a string.
  let trimmedString = string.trim();
  return trimmedString.length === 0;
}
Comments can't be checked with the tests used here. It follows a task where you have to apply much of what you have learned so far.

Exercise

Write a function median that takes an array of ascending numbers and returns the median of that numbers.

Example: median([1, 2, 10]) should return 2 and median([1, 2, 10, 100]) should return 6.
The median of a sorted series of numbers is the value in the middle. If the number of values is even, the median is the mean of the two middle numbers.
function median(nums) {
  let len = nums.length;
  if (len % 2 === 0) {
    return (nums[len / 2] + nums[(len / 2) - 1]) / 2;
  } else {
    return nums[(len - 1) / 2];
  }
}

loving