so this is a bit trippy.
tldr; i think my original answer should have been marked correct, and the reason i didn’t see the ReferenceError wrt the newTrackArray
error is because it is not actually an error - it’s a global variable - and the error did not show up for me originally because I had also modified the line(s) at the bottom of the editor (which is prob not generally advisable), thus seemingly/potentially confusing the evaluation function.
i was/am pretty sure i didn’t see that error before – until i just checked again by copy/pasting my own code from here back into the editor, like @ILM suggested.
so in going back to try to figure out why i might not have seen it before, i was able to replicate (probably?) what was happening before.
first, i think my solution was generally ‘correct’ in that it should have satisfied the requirements of the exercise. that is, if you inspected the object at the end, it would have been exactly what it should have been.
(tldr; i think it is javascript-legal to declare/use variables without explicitly declaring them with a ‘var’ or ‘let’ keyword – they just become global vars, which is prob not generally a good thing, even if they’re syntactically valid.)
second, i think it’s good that the evaluation mechanism at least highlights, in background-red, potential variable problems (as it does sometimes in my testing), and in other times actually explicitly points out and logs a ‘ReferenceError’ - as pointed out by @ILM.
and the key to my changing results are the updateRecords()
and console.log()
statements i added/changed at the bottom of the editor (my bad!).
so, what i saw initially is shown in the screenshot below:
-
newTrackArray
is not declared with var
- i commented out my later-added javascript function calls to
updateRecords()
and console.log()
– seen in green.
- only one test fails
- there is no ReferenceError shown (due to
newTrackArray
)
-
newTrackArray
is not highlighted in red in this specific scenario, but it is in others – depending on whether I have modified/added/removed any other functions to the bottom of the editor (this is a cool feature)
so that kind of gets to why i originally asked how answers are evaluated.
i do think there is something small here to improve, if it’s possible to articulate it.
- i think my original solution should be evaluated to ‘correct’ – all tests should pass
- we can maybe be explicit about requiring the use of only local variables
- maybe we can avert any ‘weirdness’ like i introduced by just adding a simple
//do not change anything below this line
as appears in other exercises
just some ideas.