/*
Using TDD, write a function that accepts an array with 1 or more integer elements
(positive or negative) and returns the element that is closest to zero; e.g.: 2 is
closer than 5; -2 is closer than 4.
In the event of a tie, e.g.: [2, -2], the function should prefer the positive version
and return that.
[-8,3,11,2,-1,4,21,-3,-2]
*/
var findClosestToZero = function () {
};
describe('the findClosestToZero function', function () {
it('should pass a sample test', function () {
expect(1).toBe(1);
});
});
// load jasmine htmlReporter - don't change
$(function () {
var env = jasmine.getEnv();
env.addReporter(new jasmine.HtmlReporter());
env.execute();
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.