Passing all tests except “10. You should log the output of calling maskEmail with email as argument.” I have the statement console.log(maskEmail(email)); in my code and see the expected output logged to the console. What about this breaks the test condition #10?
Your code so far
function maskEmail(email){
let atIndex = email.indexOf("@")
let head=email.slice(0,1);
let tail=email.slice(atIndex-1);
let masked = "*".repeat(atIndex-2);
return head+masked+tail;
}
let email="apple.pie@example.com"
console.log (maskEmail(email));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
I’ve been paying no attention to whitespace. Is it fair to say that whitespace is insignificant in JavaScript (automatic semicolon insertion notwithstanding) but freeCodeCamp enforces some style conventions?
At the very least it makes your code look messy and amateurish. It’s slightly harder to read for other people, which is important when you share your code and asking for help from other people who have to read it.
freeCodeCamp does run JS in something called strict mode which does have more strict syntax requirements than other environments. However, you didn’t get a syntax error so I don’t think this was related to that. It might have interfered with the test on the back end though, I would have to investigate that further…
I would encourage you to type well formatted code, however you can also right-click in the editor and select “format document”. Most programmers would have an auto-formatter installed that formats their code every time they save.