Hey folks. how are you today?!
Today I saw a cool and interesting JavaScript challenge and thought I'd bring it to our community too!
Soo...
...
For further actions, you may consider blocking this person and/or reporting abuse
See Computed Property Names
I'd ask questions about this "challenge":
getCorrectDescriptionwhich implies string, but it's expected to return an object shaped similarly to the hard-coded patterns. Is this an oversight or intentional?patternNameis not found inpatterns? Should it return an empty object ({})?without the
if(...)you get:{ XYZ: undefined }. Now you get just undefined which might cause trouble, if the result is expected to be an object.The return without a value definitely needs to be handled separately, and this if is just an example to avoid getting the original value of the patterns:
Hy,
what´s wrong about this solution?
This returns a well formed object in any case.
Look at my code, you will find where the problem lies
I only see that your code delivers a strange result and that it is not able to deal with unknown values. Look here. What is it good for?
What about this?
Similar solution to Jaydeep Pipaliya, written in TypeScript.
...
return patterns.hasOwnProperty(patternName)
? { [patternName]: patterns[patternName] }
: null;
...
I take it you're not used to taking time off from work. As a family psychologist by profession, I would say that you are at risk of internal burnout