We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
勘误范围:第一次印刷
图中红色箭头处 '0' 应该替换为参数 ch,,并在map后面添加join(''),完整代码如下
'0'
ch
join('')
function leftpad(str, count, ch = '0') { return `${[...Array(count)].map((v) => ch).join('')}${str}`.slice(-count); }
上面代码,在浏览器里能够得到正确的结果,如下图:
The text was updated successfully, but these errors were encountered:
function leftPad(str, count, ch = '0') { return `${[...Array(count)].map((v) => ch)}${str}`.slice(-count).join(''); }
打开console,试一下,依然不对。
Sorry, something went wrong.
补充个正解
function leftPad(str, count, ch = '0') { return `${[...Array(count)].map((v) => ch).slice(-(--count)).join('')}${str}`; }
嗯嗯,参考你的已经修改了答案,你这个还有点小问题,count的计算不对,如下图:
No branches or pull requests
勘误范围:第一次印刷
图中红色箭头处
'0'
应该替换为参数ch
,,并在map后面添加join('')
,完整代码如下上面代码,在浏览器里能够得到正确的结果,如下图:
The text was updated successfully, but these errors were encountered: