I scored 4 out of 6. But if I wasn't able to run them as I went, it would be much lower.
Also, I feel like you should add "2"+4 right after 2+"4", b/c I was definitely wondering if the casting decision was based on which one was first. Eg in Ruby, + is a method call, so 2+"4" would be calling Integer#+ and "2"+4 would be calling String#+, thus the ordering implies different behaviour, even though + in math is commutative. I know that's not how JS works, but it means that I would at least be entertaining the possibility of non-commutativity.
null===undefined// expected: false// actual: false// score: 1/1null==undefined// expected: false... but less confidently :/// actual: true// score: 1/22+"4"// expected: Jesus >.< uhm... 6? If not 6, than 24, pretty sure// one of them gets cast, just not sure which.// actual: fuuuuuuck, 24 >.<// score: 1/32-"3"// expected: Based on the above, I'm really hoping it's -1// actual: -1// score: 2/4""+2// expected: Oh fuck. uhhhh. maybe it comes in as zero, or maybe// it gets treated like a character string instead of// a number string, which maybe casts the 2 to a string// ...wait, yeah, it's definitely "2"!// actual: "2"// score: 3/5+"2"// expected: Probably 2, right? I'd expect it to cast the "2" to// a number and then make it "positive" or something.// actual: 2// score: 4/6
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I scored 4 out of 6. But if I wasn't able to run them as I went, it would be much lower.
Also, I feel like you should add
"2"+4
right after2+"4"
, b/c I was definitely wondering if the casting decision was based on which one was first. Eg in Ruby,+
is a method call, so2+"4"
would be callingInteger#+
and"2"+4
would be callingString#+
, thus the ordering implies different behaviour, even though+
in math is commutative. I know that's not how JS works, but it means that I would at least be entertaining the possibility of non-commutativity.