In this example I try to log the planet weight of Jupiter if the earth weight was 100. But the function responds with the first if statement, in this case Mercury and gives me this: 37.8
I’m also getting an error like megacoder73951 but I don’t get it (even after reading the linked FAQ for tipCalculator). Can someone please explain how I can solve this with if/else and not switches?
The double equal is the coercive comparison that will do its best to compare two unmatched data types, such as, 1 == '1', which is truthy when one operand is coerced to the same type as the other. Best practice would be to avoid this and use only strict type matching, ===
1 === '1' => false
In JS we never compare with a single equals sign. That is for assignment, only.