function maskify(cc) {
var string = cc.toString();
var arr = string.split("");
for (var i = 0; i < arr.length-4; i++){
arr[i]="#"
}
return arr;
var masked = arr.join(" ");
}
console.log(maskify(98768777656));
console.log(masked);
// Anyone knows what am I doing wrong??
your var masked is local scope
you can moved your console.log masked under the var masked
you are returning the array
everything after a return statement is not executed
maybe review where is your return statement andwhat you are returning
Thanks!!! i spend 2 hours with this.
here is the right code, thanks a lot!.
function maskify(cc) {
var string = cc.toString();
var arr = string.split("");
for (var i = 0; i < arr.length-4; i++){
arr[i]="#"
}
var masked = arr.join(" ");
return masked;
}
console.log(maskify(98768777656));
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
Also, if you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
Thank you.