initial commit
commit
6625e5ccd3
@ -0,0 +1,12 @@
|
||||
function converter(toUnit, factor, offset, input) {
|
||||
offset = offset || 0;
|
||||
return [((offset+input)*factor).toFixed(2), toUnit].join(" ");
|
||||
}
|
||||
|
||||
var milesToKm = converter.curry('km',1.60936,undefined);
|
||||
var poundsToKg = converter.curry('kg',0.45460,undefined);
|
||||
var farenheitToCelsius = converter.curry('degrees C',0.5556, -32);
|
||||
|
||||
milesToKm(10); // returns "16.09 km"
|
||||
poundsToKg(2.5); // returns "1.14 kg"
|
||||
farenheitToCelsius(98); // returns "36.67 degrees C"
|
@ -0,0 +1,24 @@
|
||||
http://www.sitepoint.com/javascript-truthy-falsy/
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition) {
|
||||
throw message || "Assertion failed";
|
||||
}
|
||||
}
|
||||
|
||||
// XXX == false
|
||||
//
|
||||
// falsy
|
||||
assert(!(false));
|
||||
assert(!(0));
|
||||
assert(!(""));
|
||||
assert(!(null));
|
||||
assert(!(undefined));
|
||||
assert(!(NaN));
|
||||
|
||||
// truthy
|
||||
assert(!!("0"));
|
||||
assert(!!("false"));
|
||||
// empty functions
|
||||
// empty array
|
||||
// empty object
|
Loading…
Reference in New Issue