This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//var reverse = require('../app/reverse'); | |
var pal = require('../app/pal'); | |
var expect = require('chai').expect; | |
describe('palindrome', function() { | |
it('it is a palindrome', function() { | |
expect(pal('racecar')).to.be.true; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
casper.test.begin("Testing if node express app", 2, function suite(test) { | |
casper.start('http://localhost:3000', function() { | |
test.assertHttpStatus(200); | |
}); | |
casper.then(function() { | |
if (this.fetchText('.daysLeft' > 0)) { | |
this.echo("more than 0 days left"); | |
} | |
this.echo("Days left: " + this.fetchText('.daysLeft')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
casper.test.begin('check if url is your blog', 1, function suite(test){ | |
casper.start('http://personal-blog-site.herokuapp.com/', function(){ | |
this.echo(this.getHTML('.nav h1')); | |
}); | |
casper.then(function(){ | |
test.assertTextExists('my blog', 'it is in fact, your blog'); | |
}); | |
casper.run(function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 2, 2, 3,3,3,3]; | |
//sort numbers in order | |
numArray.sort(function(a, b) {return a-b;}); | |
//empty array to store results | |
var result = []; | |
//loop through array | |
for (var i = 0; i < numArray.length; i++) { | |
//compare results | |
if (numArray[i + 1] === numArray[i]) { | |
//push duplicates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Find the median | |
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 17, 25, 200]; | |
numArray.sort(function(a, b) {return a-b;}); | |
//log the contents of the array | |
console.log(numArray); | |
//log the array length | |
console.log("array length is: " + numArray.length); | |
//Split the array in half |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Find the median | |
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 17, 25, 200, 210, 60]; | |
numArray.sort(function(a, b) {return a-b;}); | |
//log the contents of the array | |
console.log(numArray); | |
//log the array length | |
console.log("array length is: " + numArray.length); | |
//Split the array in half |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Find median with console.log | |
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 17, 25]; | |
//sets array in order | |
numArray.sort(function(a, b) {return a-b;}); | |
//splits array in half | |
var middle = Math.floor(numArray.length / 2); | |
console.log("the length in half is: " + middle); | |
//logs two middle numbers when array length is even | |
console.log("middle nums when array length is even: " + numArray[middle - 1] + " " + numArray[middle]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numArray = [2, 4, 6, 4, 8, 10]; | |
numArray.sort(function(a, b) {return a-b}); | |
console.log(numArray); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Find mean | |
var numArray = [2, 4, 4, 6, 8, 10]; | |
var mean = 0; | |
for (var i = 0; i < numArray.length; i++) { | |
mean += numArray[i]; | |
} | |
//logs the length of the array | |
console.log(numArray.length); | |
//logs the result of adding the intengers in the array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#goto the node website | |
#click download | |
#click the source download | |
#go to the director you downloaded the source to | |
tar -xzvf <the node tar.gz you downloaded> | |
cd <node directory> | |
./configure --prefix=~/.node | |
make && make install | |
#add the following to your .bashrc or .profile |