Ruby-like Question: Make this function shorter (ActionScript 3)

前端 未结 9 1201
春和景丽
春和景丽 2021-01-14 01:38

I just wrote this incredibly verbose code to turn numbers like 2 into 02. Can you make this function shorter, please (maintaning the functionality)?

9条回答
  •  忘掉有多难
    2021-01-14 01:57

    "If anybody wants to post some extremely short equivalent in some other language, that would be fun too."

    In javascript it is easy - paste this into your browser's address bar

    javascript: function zit(n, w) {var z="000000000000000000"; return (z+n).substr(-w);} alert(zit(567, 9)); void(0);

提交回复
热议问题