Credit Card Checker

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-challenge-project-credit-card-checker/projects/credit-card-checker

function validateCred(arr) {

arr.map(element => element * 2)

}

console.log(validateCred(mystery5))

why does this card print undefined to the console?

Check the solution from your previous post:
https://discuss.codecademy.com/t/javascript-practice/599543

It’s the same issue.

I’m honestly not understanding the issue. Can you elaborate on the issue for me if possible?

Oh I think I’m getting it. When you use {}, then you need a return command?

You are using the classic syntax for your function:

function xy(x) {
   return x*2
} 

This is more or less the same as if you use the ES6 syntax:

const xy = (x) => {
  return x*2
}

There are minor differences like hoisting and the use of this keyword, but that does not matter in this context.

Then there is the shorthand syntax where the return is implicit:

const xy = (x) => x*2

Yes

2 Likes

That sounds more clear to me now. Thank you so much for your help!

1 Like