Varsnap Demo: Fibonacci Number Calculator

Fibonacci Calculator Code
// Varsnap configuration // See the installation page at https://www.varsnap.com/install/ for more information varsnap.varsnap.config = { varsnap: true, env: 'development', producerToken: 'producer-umakrqit4l021plfg75q', consumerToken: 'consumer-tz1ffce4u9lepxjamw6b', logger: logger, // shim to pipe logs to the Output window }; // Function for calculating fibonacci numbers var calculateFibonacci = varsnap.varsnap(function calculateFibonacci(index) { if (index <= 0) { return 0; } if (index == 1 || index == 2) { return 1; } return calculateFibonacci(index - 1) + calculateFibonacci(index - 2); }); // Callback function for to bind calculateFibonacci with the // demo "Calculate" button function submitFibonacci() { var fibonacciIndex = $("#fibonacciIndex").val(); var fibonacciValue = calculateFibonacci(fibonacciIndex); var output = $("#fibonacciOutput"); var outputText = 'Fibonacci number ' + fibonacciIndex + ' is ' + fibonacciValue; output.text(outputText); return false; }
Varsnap Output

1. Run the fibonacci calculator.
This runs the code in the above IDE and seeds Varsnap with production cases.


 

2. Test the code in this IDE
Run tests on your code above by replaying production test cases against your current code.


3. Log into the demo user acount to view debug info
Your Varsnap user account contains recorded Snaps and test results to debug from.

Login to Demo Account