Skip to content

Instantly share code, notes, and snippets.

@al-the-x
Created September 18, 2015 19:37
Show Gist options
  • Save al-the-x/79a97519ca10700b0a65 to your computer and use it in GitHub Desktop.
Save al-the-x/79a97519ca10700b0a65 to your computer and use it in GitHub Desktop.
Coding Dojo @ TIY-Durham on 2015-09-18 with 2015-FALL-FEE!
var expect = require('chai').expect;
/**
* write a function `max` that takes two `Numbers` as arguments
* and returns the largest of them. HINT: Use `if-else`...!
*/
it('should calculate the max of two Number', function(){
// expect(max(1,3)).to.be.equal(3);
expect(max(2,4)).to.be.equal(4);
expect(max(2,6)).to.be.equal(6);
expect(max(2,8)).to.be.equal(8);
expect(max(2,1)).to.be.equal(2);
expect(max(null,1)).to.be.equal(1);
expect(max(NaN,1)).to.be.equal(1);
// expect(max(2,"cat")).to.be.equal();
// expect(max(0,3)).to.be.equal(3);
// expect(max(10,3)).to.be.equal(10);
// expect(max(-1,-3)).to.be.equal(-1);
// Why would you do this?
// expect(max("aaa",0)).to.be.equal(0);
// Okay, that's just silly...
expect(isNaN(max("aaa","bbb")));
}); // END test(max)
/**
* @param {Number} A to compare to B
* @param {Number} B to compare to A
* @return {Number} the greater of A or B
*/
function max(A, B){
if (A > B) {
return A;
}
return B;
}
/**
* Write a function `maxOfThree` that takes _three_
* `Numbers` as arguments and returns the largest of them.
*/
it('should calculate max of THREE Number', function(){
expect(maxOfThree(1,2,3)).to.be.equal(3);
expect(maxOfThree(1,2,4)).to.be.equal(4);
expect(maxOfThree(1,2,0)).to.be.equal(2);
// expect(maxOfThree(10,3,50)).to.be.equal(50);
// expect(maxOfThree(-1,-3,-10)).to.be.equal(-1);
// Look, that's just mean...
// expect(maxOfThree("aaa",0,1)).to.be.equal(1);
// Who's running this picture, anyway?
// expect(isNaN(maxOfThree("aaa","bbb","ccc")));
}); // END test(maxOfThree)
/**
* @param {Number} A
* @param {Number} B
* @param {Number} C
* @return {Number} greatest of A, B, and C
*/
function maxOfThree(A, B, C){
var condition = false;
if (condition){
console.log('Hallo!');
}
return C;
}
/**
* Write a function `isVowel` that takes a character
* (i.e. a `String` of length 1) and returns a `Boolean`
* indicating whether the input is a vowel or not.
*/
it('should know what letters are vowels', function(){
// What a cruel, cruel master you are...
// expect(isVowel(0)).to.be.equal(false);
//
// expect(isVowel("B")).to.be.equal(false);
// expect(isVowel("b")).to.be.equal(false);
// expect(isVowel("a")).to.be.equal(true);
// expect(isVowel("E")).to.be.equal(true);
// What should _this_ do?
// expect(isVowel("AEIOU")).to.be.equal(FILL_ME_IN);
}); // END test(isVowel)
/**
* @param {String} char of length 1
* @return {Boolean} whether `char` is an English vowel
*/
function isVowel(char){
// YOUR CODE HERE
}
/**
* The `disemvowel` function combats the Internet
* Trolls by handily removing all of the vowels from
* their angry, hurtful comments. It's Super-Effective!
*
* @param {String} comment to disemvowel
* @return {String} cmmnt dsmvwld
*/
function disemvowel(comment){
// YOUR CODE HERE
}
it('should disemvowel troll comments', function(){
// Shorter test cases might be appreciated...
// expect(
// disemvowel("This website is for losers LOL!")).to.be.equal("Ths wbst s fr lsrs LL!"
// );
}); // END test(disemvowel)
/**
* The function `rovarspraket` will translate text into
* a "rövarspråket", i.e. double every consonant and
* place an occurrence of "o" in between them.
*
* For example, `rovarspraket("this is fun")` should
* return `"tothohisos isos fofunon"`
*
* @see https://en.wikipedia.org/wiki/R%C3%B6varspr%C3%A5ket
*
* @param {String} text to translate into "rövarspråket"
* @return {String} translation
*/
function rovarspraket(input){
// YOUR CODE HERE
}
it('should maken zee rovarspraket', function(){
// Feel free to provide additional examples...
// expect(rovarspraket("a")).to.be.equal("a");
// expect(rovarspraket("b")).to.be.equal("bob");
// expect(rovarspraket("cat")).to.be.equal("cocatot");
// expect(rovarspraket("javascript")).to.be.equal("jojavovasoscocroripoptot");
// expect(rovarspraket(0)).to.be.equal("0");
}); // END test(rovarspraket);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment