Week 5, day 1
This week's exercises are all about Javascript, a language not entirely alien to a Rubyist. It can be object or function oriented but it doesn't have classes at all, or objects in the same sense as Ruby. The nice thing is that its testing language, Jasmine, is quite similar to Rspec.
The weekly challenge begins with some Javascript exercises including a version of FizzBuzz and then moves on to creating a thermostat app. All test-driven of course.
1 var Thermostat = function () {
2 this.temp = 20;
3 };
4
5 Thermostat.prototype.increase = function(){
6 this.temp += 1;
7 return(this.temp);
8 };
Above is the beginnings of my partner and I's thermostat app, allowing the unit to be created with a default temperature and endowing temperature increase and decrease functionality.
Below are some of the tests.
1 describe('thermostat', function() {
2
3 var thermostat;
4
5 beforeEach(function() {
6 thermostat = new Thermostat();
7 });
8
9 describe('A new thermostat has', function() {
10
11 it('a default temp of 20', function() {
12 expect(thermostat.temp()).toBe(20);
13 });
14
15 it('a button to increase temp by one', function(){
16 thermostat.increase();
17 expect(thermostat.temp()).toBe(21);
18 });
19
20 });
21 });
We're also encouraged to re-do in Javascript all the projects we've completed in Ruby, the Airport challenge, Takeaway challenge, Rock-Paper-Scissors challenge and Chitter challenge. Apart from learning how JS likes its syntax everything else seems really manageable, going to be a fun week I think.
The seniors will be presenting their final projects and graduating this Friday, at which point us juniors will become seniors and the new cohort will be joining the Academy. We've already been assigned mentees to mentor, I'm particularly proud of my mentee, she shows a passion for code and competitiveness.