Instantly share code, notes, and snippets.

# bbraithwaite/calculator.jsSecret Last active Dec 28, 2018

 var calculator = { sum: function (x, y) { return x + y; }, subtract: function (x, y) { return x - y; }, divide: function (x, y) { return (y === 0) ? 0 : x / y; } } describe('calculator', function () { describe('sum', function () { it('1 + 1 should equal 2', function () { expect(calculator.sum(1, 1)).toBe(2); }); }); describe('subtract', function () { it('3 - 2 should equal 1', function () { expect(calculator.subtract(3, 2)).toBe(1); }); }); describe('divide', function () { it('10 / 5 should equal 2', function () { expect(calculator.divide(10, 5)).toBe(2); }); it('zero divisor should equal 0', function () { expect(calculator.divide(10, 0)).toBe(0); }); }); });

### micronyks commented Nov 17, 2015

 Thanks for you tutorial. At least and last came to know how exactly it works !

### optimized4u commented Apr 15, 2016

 Thank you for great starting tutorial, now on to the next.

### rjgferreira commented Jun 18, 2016

 Excellent didactic! Thank you for this light!

### nbkhope commented Aug 8, 2016

 Thank you 👍

### Shafiuzzaman-Hira commented Aug 9, 2016

 Thanks a lot. This was really helpful to start the journey.

### erick2014 commented Sep 7, 2016

 awesome tut man!

### kapillohakare123 commented Sep 14, 2016

 Thank you for this introductory tutorial. Helped a lot for me.

### ancilt26 commented Oct 10, 2016

 Such an awesome tutorial dude, really concise and everything! Thanks heaps! :)

### aerojeyenth commented Nov 10, 2016

 Really Helps. Thanks for this getting started tutorial.

### AlayVora commented Jul 12, 2017

 Really helped. keep up the good work

### bennawanda commented Aug 9, 2017

 Could someone tell me how to test this block? In typescript and angular 2. In short, I would like to know how to access and set a function's local variables like in this case. `````` test(): any { var value = 2; if(value === 2){ return true; }else{ return false; } } ``````

### rehan544 commented Nov 6, 2017

 nicely explained ...!

### elyr commented Dec 28, 2018

 thank you 👍