Skip to content

Instantly share code, notes, and snippets.

@suhaotian
Created August 14, 2016 16:41
Show Gist options
  • Save suhaotian/26472e8ccc18206151179646a1453146 to your computer and use it in GitHub Desktop.
Save suhaotian/26472e8ccc18206151179646a1453146 to your computer and use it in GitHub Desktop.
const unit = {
// @todo
}
function SmartNumber(n) {
if (typeof n === 'number') {
if (n<1e3) {
return n
} else if(n<1e4) {
return [n/1e3, '千']
} else if(n<1e6) {
return [n/1e4, '万']
} else if(n<1e7) {
return [n/1e6, '百万']
} else if(n<1e8){
return [n/1e7, '千万']
} else {
return [n/1e8, '亿']
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment