I am a full stack engineer, passionate about solving complex problems and collaborating with driven teams! I have 4+ years of experience working at small to mid sized startups.
made the function to support also other data types of input..
changed naming and simplified return statement (new Set() is not ran if result.length > 1 fails first).
yes.. that is why end result size should be 1
[1,1,1] => [1]
the code checks first that the initial array has more than 1 input so
[1] => [1]
would fail on the first length check
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.
This solution allows n-amount of inputs and uses Set to check all items are the same.
Nice!
made the function to support also other data types of input..
changed naming and simplified return statement (new Set() is not ran if result.length > 1 fails first).
Doesn't Set remove duplicates?
yes.. that is why end result size should be 1
[1,1,1] => [1]
the code checks first that the initial array has more than 1 input so
[1] => [1]
would fail on the first length check