Warmup - Unique Name
Part One
Define a function in JavaScript named addUniqueName
that has two parameters - one called name
of type String
and the other called names
of type Array
.
The function will take the name
and add it to the names
array only if that name is not already in the array.
You CANNOT use any type of for loop to solve this problem.
Part Two
Change the parameter names
be of type Object
instead of Array
.
Add a new key/value pair to the names object only if unique.
This will change how your code from part one works.