I'm in the camp that believes that closing a question as a duplicate means that either
this question is a clear duplicate of the (presumably well-answered) other one. (In Javascript, where I spend much of my SO time, this might be a pointer to How do I return the response from an asynchronous call? for the many times someone asks a nearly identical question.)
the accepted -- or the top-voted -- answer there will answer this question with little ambiguity. (In JS this might be a pointer to How do JavaScript closures work?, which can explain many different behaviors that seem odd to newcomers.)
In other circumstances, I will usually choose not to close them. I do wish there was a reputation level that allowed users to vote against closing question rather than waiting for a close and voting to reopen.
Here the OP was reporting a "Whiteboard problem". Whether that's an actual interview-style code-this-in-front-of-us question or one of the myriad code-and-compete-to-learn sites, I don't know. Either way, I assumed that the OP was trying to learn in this exercise, rather than just solving the immediate practical problem. This was reinforced by:
I use sorting to find the shortest string. (not best practice but hey i'm learning).
But I don't know if making that call is appropriate. I've been around a while and I tend to want to close as a duplicate only when it's really obvious. This is amplified by the OP being very new to SO. But this viewpoint may be counterproductive, and I'd love to hear if it is from those more experienced or those more active in meta.
let unsorted = arr;
if they were asking how else to solve it i'd maybe agree, but... they aren't, they're asking why it didn't worklet
? should I be usingconst
instead?" - clearly they are searching for something they aren't sure of. It's clearly asking for an improvement over their current approach in any case. The dupe shows the issue but only a specific way of addressing it, that doesn't cover the all possibilities in this case. I don't think we should be applying the XY problem in reverse and binding the user to a Y solution.unsorted.map
is returning a sorted array. I have no idea why." - That is what they want to solve, and they know thatlet
orconst
on the line of code they are trying to copy the array. They are basically asking whether to uselet unsorted = arr;
orconst unsorted = arr;
. Neither will work because that's not how you copy arrays in javascript and the close question solves exactly that.