Skip to content

Instantly share code, notes, and snippets.

@3mcd
Last active December 17, 2015 18:07
Show Gist options
  • Save 3mcd/d79f50afc83e3de18dee to your computer and use it in GitHub Desktop.
Save 3mcd/d79f50afc83e3de18dee to your computer and use it in GitHub Desktop.
{% exercise %}

Using the mean() function above, find the mean of `x`, `y`, and `z`, and assign it to `result`.

{% initial %}
var x = 5, y = 10, z = 20;
var result = ;

{% solution %}
var result = mean(x, y, z);

{% validation %}
assert(result == mean(x, y, z));

{% context %}
function mean() {
  var args = Array.prototype.slice.call(arguments);
  return args.reduce((a, x) => a + x, 0) / args.length;
}

{% endexercise %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment