What does it mean that my code makes "comparisons against strings"?

Asked

Viewed 57 times

0

The exercise calls for the following:

Set the function Hipster which takes as a parameter: a person’s profession (string), nationality (string) and the number of kilometers he walks per day (number). With these parameters evaluate whether or not this person is a Hipster (true / false). Keep in mind that a Hipster is a Musician, born in Brazil and who likes to walk more than 2 kilometers a day.

There my code:

function Hipster(profissao,nacionalidade,kms){
  return profissao==="Músico" &&
    nacionalidade==="Brasil" &&
    kms>2;
  
}

Even accepting as valid, the platform ALWAYS returns with the message that the code "makes comparisons against strings" as if it were something wrong and I don’t know what that means.

  • 1

    Something that only the context can indicate well, and maybe only those who wrote it can say what it is, probably a wrong term and a bad place to learn, even for being an ambiguous term. These days gave a flurry of bad questions starting from some bad site that tries to help people learn JS, this will not work. I could kick some stuff, but kicking doesn’t help much.

  • 3

    Apparently he’s popping up on an online "good practice" platform (which is terrible). I say this for a series of questions of this type that is appearing on the site. After the staff does not know the reason of programmer with technical basis to be an almost extinct race. Capable of platform such not to like Magic Numbers or Magic strings, but without context or link with adequate explanation, the message itself is useless. I would only give a "discount" if the platform of this specific test here has presented a lesson about it and it is failure of those who did the exercise have not seen a statement requirement.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.