Practice comparing different values (recommendation for changing exercise)

Is there a way to make a recommendation for changing an exercise?

function compareEquality(a, b) {
  if (typeof a === typeof b) { // Change this line
    return "Equal";
  }
  return "Not Equal";
}

The lesson that goes through this is not explicitly clear of what is going on specifically in this example. It looks like it is trying to do several things at once but for someone who doesn’t understand coding, they probably wouldn’t understand this at all. I think this could be written better to be more clear. I get the author’s intent, but it is quite confusing as the examples are all split up.

Maybe add several test cases showing what exactly is being compared here. For example,

“1” == “1” // true
“1” == 1 // true because JS converts types
“1” === “1” // true because both are string values and values are equal
“1” === 1 // false because there is no type conversion
typeof “1” === typeof “1” // true because string type
typeof “1” === typeof 1 // false because different type

Am I overthinking this?

Which challenge are you working on? Have you done the next challenge as well?

Yes, but I think the questions could be structured better for future students…

I have no idea which challenge you are talking about, so your comments have no context for me. I cannot comment intelligently upon what you are saying unless you provide more detail.

HI @Nematode !

Welcome to the forum!

I have edited your post with the challenge link.
Now we have some better context on what you are talking about.


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 (’).

I understand the need for more examples in beginner exercises.
But we also have to remember that most people don’t read all of the instructions and examples.

I think adding more text to the example would make people tune out.

That’s just been my personal experience helping people on the forum.
But would love to hear other people’s thoughts. :grinning:

1 Like

There already is one example in this lesson

3 == '3' returns true because JavaScript performs type conversion from string to number. 3 === '3' returns false because the types are different and type conversion is not performed.

I’m not sure that flooding learners with a bunch of examples would help in this case.


There is a trio of lessons on this topic that seem pretty comprehensive.

Weak equality:

Strict equality:

More practice:

And these three are followed by two lessons on weak and strict inequality… so 5 lessons covering the distinction between strict and weak seems pretty good to me.

Maybe I’m missing something though?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.