Last active
December 19, 2015 07:49
-
-
Save pid/5921689 to your computer and use it in GitHub Desktop.
Solutions: Jasper - JavaScript, Assessment of Skills with Peer Evaluation and Review
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
/* global Jasper */ | |
/* http://kalisjoshua.github.io/Jasper/ */ | |
Jasper('start'); | |
// "Pass in a function that returns true." | |
Jasper(function() { | |
return true; | |
}); | |
// "Provide an object with two properties: 'a' and 'b'." | |
Jasper({ | |
a: 1, | |
b: 1 | |
}); | |
// "Pass a function that throws an error with message 'up'" | |
Jasper(function() { | |
throw new Error("up"); | |
}); | |
// "Send a JSON string that has a property 'do' with the value 'good'" | |
Jasper('{"do":"good"}'); | |
// "Write a function to sum any number of number arguments." | |
Jasper(function addany() { | |
var idx, sum = 0; | |
for (idx in arguments) { | |
sum += arguments[idx]; | |
} | |
return sum; | |
}); | |
// "Write a function that takes an argument and returns a function that returns that argument." | |
Jasper(function(v) { | |
return function() { | |
return v; | |
}; | |
}); | |
// "Execute Jasper with a context that matches its argument." | |
Jasper.call(this, this); | |
// "Add a 'jasper' method to the prototype of the object passed to the function your write." | |
Jasper(function(obj) { | |
obj.prototype.jasper = function() {}; | |
}); | |
// reset | |
Jasper('reset'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment