Skip to content

Instantly share code, notes, and snippets.

Introduction to Objects

Lesson

Slides

Exercises

Basic Requirements

Introduction to Abstraction

Lesson

Slides

Exercises

function each(coll, func) {

Slides

  1. Write a function called average that takes an array of numbers as a parameter and returns the average of those numbers.

    After you write your function, you can test it using the above inputs to make sure that it behaves correctly.

  2. Write a function called min that finds the smallest number in an array of numbers.

function square(x) {
return x*x;
}
describe("sumDigits", function() {
it("should return a number", function() {
expect(typeof sumDigits(2002)).toBe("number");
});
it("should sum the digits of a positive number", function() {
expect(sumDigits(2002)).toBe(4);
});
it("should sum the digits of a negative number", function() {
expect(sumDigits(-2004)).toBe(2);
});
body { overflow-y: scroll; }
.jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
.jasmine_html-reporter a { text-decoration: none; }
.jasmine_html-reporter a:hover { text-decoration: underline; }
.jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; }
.jasmine_html-reporter .jasmine-banner, .jasmine_html-reporter .jasmine-symbol-summary, .jasmine_html-reporter .jasmine-summary, .jasmine_html-reporter .jasmine-result-message, .jasmine_html-reporter .jasmine-spec .jasmine-description, .jasmine_html-reporter .jasmine-spec-detail .jasmine-description, .jasmine_html-reporter .jasmine-alert .jasmine-bar, .jasmine_html-reporter .jasmine-stack-trace { padding-left: 9px; padding-right: 9px; }
.jasmine_html-reporter .jasmine-banner
/*
Copyright (c) 2008-2016 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
/*
Copyright (c) 2008-2016 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hack Reactor Prep Test Runner v1.0</title>

<link rel="stylesheet" href="https://cdn.rawgit.com/reactorcore/prep-codepen-tests/00c84c30/jasmine/hr-jasmine.css">

<script src="https://cdn.rawgit.com/reactorcore/prep-codepen-tests/00c84c30/jasmine/hr-jasmine.js"></script>
<script src="https://cdn.rawgit.com/reactorcore/prep-codepen-tests/00c84c30/jasmine/hr-jasmine-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.5.2/boot.min.js"></script>