Week02

Here are a couple projects we can work on in class. If you don’t have time to finish them in class, try to get them as soon as you can. I will, however, note the date of your submission.

Project01

  • Create a project called MilesObject
  • Add Index.js
  • Add JavaScript object called milesConvert
  • Add two fields: miles property, set it to 3
  • Add feetPerMile, set it to 5280
  • Add method called milesToFeet and implement it
  • Call your method
  • Add Jasmine Test
  • Make sure your code passes JSHint

Optional (for now):

  • Add Grunt JsHint support
  • Add QUnit Test
  • Add Karma Support

Project02

  • Create a project in Aptana called MilesFunction
  • Like above, but make the object be a JavaScript Function, not an object.
  • Add index.js
  • Add JavaScript function called milesConvert
  • Repeat above, but pass in miles as parameter

Some hints on how to create the function:

var MyFunc = function() {

	var name = 'sam';

	this.sayName = function() {
		console.log(name);
	};
};

var myFunc = new MyFunc();
myFunc.sayName();

You will need to call new in your tests:

it ("can create milesFunction", function() {
	expect(new milesFunction()).toBeTruthy();
});