Skip to content

Instantly share code, notes, and snippets.

@lsongdev
Created March 20, 2017 07:14
Show Gist options
  • Save lsongdev/83fe78e76678e9e49d402a9daea3e3b8 to your computer and use it in GitHub Desktop.
Save lsongdev/83fe78e76678e9e49d402a9daea3e3b8 to your computer and use it in GitHub Desktop.
// http://wiki.sankuai.com/display/DEV/MBTI_Result
var o = $('#main-content').html().match(/[EINSTFJP]{4}/ig).map(x => x.toUpperCase())
.reduce(function(o, x, i, a) {
o[x] = o[x] || {};
o[x].n = (o[x].n || 0) + 1;
o[x].p = ((o[x].n / a.length) * 100).toFixed(2);
return o;
}, {});
Object.keys(o).sort((a,b) => o[b].n - o[a].n).forEach(function(n, i){
console.log(n, o[n].p);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment