To clarify , == (equality operator) in JavaScript will convert types when comparing.
For example, return 5 = '5' will return true even though it is comparing a number and a string.
This is because JavaScript will convert them to the same type when comparing.
Using === (strict equality operator) will not convert type so the above example would return false
Your solution is not good. Every good boy just use O(1) memory and O(n) time, you use O(n) memory.
In the example there is a little typo
=
should be==
To clarify ,
==
(equality operator) in JavaScript will convert types when comparing.For example,
return 5 = '5'
will returntrue
even though it is comparing a number and a string.This is because JavaScript will convert them to the same type when comparing.
Using
===
(strict equality operator) will not convert type so the above example would returnfalse
A funny solution!
This comment is hidden because it contains spoiler information about the solution
...why codewars don't set code limit?
Nice idea!
==
is never enough.==
bites.==
is inexplicable bugs waiting to happen.===
is much more predictable and untemperamental.It works! But I can't understand this, could someone help me?
Nice solution! But I think '==' is enough.
Nice solution!