Skip to content

Instantly share code, notes, and snippets.

@RhinoLu
RhinoLu / gist:ab3b0d88c79d6a479a46
Created November 1, 2015 13:43 — forked from tony1223/gist:ac9aec20561112e6e43c
台灣身分證檢查
function identify(check){
var type = {a:10, b:11, c:12, d:13, e:14, f:15, g:16, h:17, j:18, k:19, l:20, m:21, n:22, p:23, q:24, r:25, s:26, t:27, u:28, v:29, w:32, x:30, y:31, z:33, i:34, o:35 };
var val = type[check[0].toLowerCase()] + check.substring(1);
var ranks = [1,9,8,7,6,5,4,3,2,1];
var checknum = 0;
for(var i = 0 ; i < ranks.length;++i){
checknum += parseInt(val[i],10) * ranks[i];