CODE CHALLENGES: JAVASCRIPT FUNDAMENTALS truthyOrFalsy() exercise Question:

Hi everybody!

I’m sorry for this noob question but although I got the solution to this problem, I don’t quite understand the following:
Why is this correct:

truthyOrFalsy = function(value) {
  if(value){
    return true
  }
    return false
  }

But this one is incorrect?

truthyOrFalsy = function(value) {
  if(value){
    return true
  } else {

    return false
  }
  }

Wouldn’t it be fair to say that both examples are correct?

Thank you very much

If by incorrect, you mean it didn’t pass the SCT, I suppose you are right in that the bottom snippet produces the same output as the top. If you post a link to the exercise, we can look at it, but there are times when the SCT wants something very specific even though it isn’t always specified in the instructions. :man_shrugging:

Here’s the link:

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-i/modules/fecp-practice-javascript-syntax-variables-data-types-conditionals-functions/lessons/javascript-fundamentals-code-challenge/exercises/truthy-or-falsy

But I would guess it’s correct either way, then… it might be, as you a said, a difference in the SCT synthax. Thank you so much for your reply.

1 Like