Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

javascript - 做Codewars JavaScript初学者挑战(Doing codewars JavaScript beginner challenge)

I just joined this highly recommended website.

(我刚刚加入了这个强烈推荐的网站。)

Hope someone can help me understand code a bit better.

(希望有人可以帮助我更好地理解代码。)

I am now doing the codewars challenge to make Credit Card Mask .

(我现在正在做代码战挑战来制作信用卡面膜。)

So i need to mask all the numbers with # and leave the last 4 visable.

(所以我需要用#掩盖所有数字,并保留最后4个可见的数字。)

Here is my code :

(这是我的代码:)

function maskify(cc) {
let mask= '' ;
let all = mask.slice()
all = all.slice(-4)
for (i = 0 ; i < mask.length ; i++){
 i += '#'
}
return mask[i] + all ;
}
maskify(2,3,2,1,3,2,1,321321)

can someone explain to me what I am doing wrong.

(有人可以向我解释我在做什么错。)

My JS knowlage is still basic.

(我的JS知识仍然很基础。)

  ask by marian nestorov translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...