为了账号安全,请及时绑定邮箱和手机立即绑定

代码优化oooooo

代码优化oooooo

长风秋雁 2018-08-17 10:09:25
function mosaicZero(var num) {    //根据num拼接字符串zero,数字num是几字符串zero就有几个0.num取值范围0-16    var zero = "";    if (num == 0) zero = "0";    if (num == 1) zero = "00";    if (num == 2) zero = "000";    if (num == 3) zero = "0000";    if (num == 4) zero = "00000";    if (num == 5) zero = "000000";    if (num == 6) zero = "0000000";    if (num == 7) zero = "00000000";    if (num == 8) zero = "000000000";    if (num == 9) zero = "0000000000";    if (num == 10) zero = "00000000000";    if (num == 11) zero = "000000000000";    if (num == 12) zero = "0000000000000";    if (num == 13) zero = "00000000000000";    if (num == 14) zero = "000000000000000";    if (num == 15) zero = "0000000000000000";    if (num == 16) zero = "00000000000000000";    return zero;}
查看完整描述

1 回答

?
当年话下

TA贡献1890条经验 获得超9个赞

var num = 5;

var result = "00000000000000000".substr(0, num);


查看完整回答
反对 回复 2018-09-19
  • 1 回答
  • 0 关注
  • 544 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信