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
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.
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.
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.
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.