A project aimed to help the user master Javascript with a test-driven approach. Each unit contains an annotated tutorial on the code itself and the ability to run Unit Tests to verify the expected behavior.
- Arrays
- Bad Practices and Solutions
- Booleans
- Built-in Functions
- Closure
- Comparisons
- Conditionals
- Exceptions
- Falsey Values
- Function Expressions
- Function Expressions as Parameters
- Functions
- General Performance
- Hoisting
- Logical Assignment
- Loops
- Namespaces
- Numbers
- Object Prototype
- Objects
- Objects Functionality
- Prototypes
- Strings
- Switch Block
- Ternary Conditionals
- Truthy Values
- Variables
/*Arrays*/
/* An array is a data structure with automatically indexed positions*/
it('Arrays can be accessed by indices', function () {
//The brackets indicate to the compiler to make an array and fill it with
//the comma-separated values between the brackets
var arrayOfStrings = [ "StringZero" , "StringOne" , "StringTwo"];
//We can access any location of the zero-based array
expect(arrayOfStrings[1]).toBe("StringOne");
});
it('You can reference and change specific cells with indices', function () {
var arrayOfStrings = [ "StringOne" , "StringOne" , "StringTwo"];
arrayOfStrings[0] = "StringZero"; //You can change the value contained at any index
expect(arrayOfStrings[0]).toBe("StringZero");
});
/*Functions take some input, executes a series of statements using the input and outputs some result*/
it('functions help write reusable code', function () {
expect(addNumbers(1, 2)).toBe(3);
expect(addNumbers(2, 3)).toBe(5);
expect(addNumbers(1 + 1, 2 + 1)).toBe(5);//Parameters can also be expressions, which the function will resolve before starting
var numberOne = 2;
var numberTwo = 3;
expect(addNumbers(numberOne, numberTwo)).toBe(5);//Parameters can also be variables
});
// function keyword tells the compiler that you are defining a function
function addNumbers(numberOne, numberTwo) { //The function's name follows the 'function' keyword and should indicate the function's purpose
//Parameters are passed in a set of parentheses before the first curly brace
return numberOne + numberTwo;
//The return keyword works as a terminating statement and exits the function returning the value in front of it
} //The statements that will be executed should be enclosed in curly braces.
npm install
bower install
grunt test
If you have any questions, please feel free to ask me: Martin Chavez Aguilar
- Martin Chavez Aguilar - Wrote the project