<script src="https://searls.github.io/jasmine-all/jasmine-all-min.js"></script>
<script type="application/javascript">
'use strict';
describe('Declaration', function() {
it('is function', function() {
var type = typeof(window.MyFunction);
expect(type).toBe('function');
});
});
describe('Execution of', function() {
var value;
it("initial sequence", function() {
value = new window.MyFunction();
expect(value.current()).toBe(1);
});
it("incrementing sequence once", function() {
value.increment();
expect(value.current()).toBe(1);
});
it("incrementing sequence three times", function() {
value.increment().increment().increment().increment();
expect(value.current()).toBe(8);
});
it("decrementing sequence two times", function() {
value.decrement().decrement();
expect(value.current()).toBe(3);
});
});
</script>
CSS
/*
INSTRUCTIONS
############
A simple algorithm based on Fibonacci sequence and prototype methods.
1. The function stores the current sequence number.
2. On each call of increment(), the current number is incremented based on next Fibonacci sequence number.
3. On each call of decrement(), should be similar, but decrementing to the last Fibonacci sequence number.
*/
JavaScript
'use strict';
window.MyFunction;
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.