Skip to content

Instantly share code, notes, and snippets.

@anibal21
Last active April 20, 2022 04:58
Show Gist options
  • Save anibal21/ee76096a8febf0e6e9a61b5511f0f2d3 to your computer and use it in GitHub Desktop.
Save anibal21/ee76096a8febf0e6e9a61b5511f0f2d3 to your computer and use it in GitHub Desktop.
JavaScript interpreter Problems
// This validation is correct, because is not undefined neither zero
if(42){
// Here we have a comparison without types (===) so, JS sees both as equals
if(42 == "42"){
// Correct
if(true){
// This have no sense, because the callstack see the first item that is an integer, and can't compare
// the boolean as a number
if(42 == true){
console.log("continue")
} else {
// This is the answer
console.log("42 is not equal to true")
}
} else {
console.log("true alone is not a conditional")
}
} else {
console.log("the parts are not equal")
}
}else {
console.log("It wasn't 42")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment