Skip to content

Instantly share code, notes, and snippets.

@twlca
twlca / array_snippets.js
Created April 28, 2017 05:14
Patch an array so it can be used as range separator. First we validate the argument is an array then check if each array element is integer. Then we add 0 and infinity to the array.
// patch an array so it add 0 as 1st element and Infinite as last element
function checkArr( arr ) {
try {
Array.isArray( arr );
} catch(e) {
console.log( 'Input arguments is not an array' );
return false;
};
// validate element types
@twlca
twlca / donators_core.js
Last active July 4, 2017 07:31
// 將資料依指定的 property 組成群組
// 要求:
// 1. 列印收據(點陣式)
// 2. 報表依捐款人、捐款金額、手續費、實收金額列印
// 3. 可供期間查詢:包含螢幕查詢及報表
// 4. 以捐款人、捐款日期、捐款種類、捐款管道分類,日期則以倒序法排列(最近的日期在最上方)
// 5. 捐款管道、手續費、捐款種類可以由使用者設定
// 6. 捐款人快速查詢:姓名排列、連絡地址排列(分類)
// 7. 捐款人組織或個人分類
var donators = [
@twlca
twlca / postalCode.json
Created May 31, 2017 07:03
郵遞區號一覽表 (JSON)
{
"台北市":
{
"100": "中正",
"103": "大同",
"104": "中山",
"105": "松山",
"106": "大安",
"108": "萬華",
"110": "信義",