<script src="//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
/*
1. Implemente uma classe utilizando prototype ou objetos literais.
2. A classe deverá armazenar um número da sequência Fibonacci.
3. A classe deverá inicializar com o primeiro número da sequência Fibonacci.
4. Ao invocar current(), o número da sequência atual é retornado.
5. Ao invocar increment(), o número atual é incrementado para o próximo da sequência.
6. Ao invocar decrement(), o número atual é decrementado para o anterior da sequência.
7. Os métodos increment() e decrement() são reutilizáveis.
*/
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.