Tell us what’s happening:
Describe your issue in detail here.
I was certain before doing the challenge, but confirmed the solution matches mine as well, but for some reason my solution keeps receiving the warning
The initial declaration of the homeworkStack should not be changed. It seems to be a bug.
Your code so far
var homeworkStack = ["BIO12","HIS80","MAT122","PSY44"];
// Only change code below this line
let top = homeworkStack.pop();
console.log(top);
homeworkStack.push("CS50");
console.log(homeworkStack)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0
Challenge: Data Structures - Learn how a Stack Works
The error seems clear. You’re changing the homeworkStack declaration.
For the test to pass, you must not change any line before the comment (the line starting with // ).
If you’re not figuring out whats wrong, please post your code so we can review it.
That is just a variable I used to catch the value that is popped() to confirm that the correct value popped.
Commenting out that code, or removing it altogether, does not resolve the issue of the failing test (“The initial declaration of the homeworkStack should not be changed”) and therefore seems moot, however, you are correct that it is different than the solution provided in the “Get a hint” section". However, when I copy the code from that section verbatim, I still end up with that failing test.
I tried it again, and it worked, which is frustrating…
I’m not sure what I was doing before that caused it not to pass, but it did.
What is most frustrating is that capturing the popped value in a variable (in my mind - which I would be more than happy to have changed) isn’t changing the initial declaration of the homeworkStack, and therefore shouldn’t cause that test to fail (as you said, it’s not a helpful error to begin with).
Sorry for venting, it just seemed such a trivial thing to cause a test to fail.