Frustrations of JavaScript (Who's in Your Bracket?)


#1

I just spent the past hour trying to figure out why the following code kept telling me "Oops, try again. There was a problem with your syntax." or "Did you forget (insert random phrase here)"

var james = {
job: "programmer",
married: false
};

// set to the first property name of "james"
var aProperty = "job";

// print the value of the first property of "james" 
// using the variable "aProperty"

console.log(james[aProperty]);

I looked up the answer to this exercise finally, only to find that it was EXACTLY what I had written, no typos, no nothing. But even copying and pasting the "Correct" answers returned the same "Invalid syntax", etc. Until finally it began working without changing a single character.

Why is this happening? I was thrown for an hour long "How the ■■■■ is this supposed to be done" trip only to find out I had been right all along but the text editor decided "No, you aren't".

What can I do to prevent this in the future? I would really appreciate not having to go through this again, it only makes me doubt myself even more because this stuff doesn't come easy to me, and having the unnecessary time added does not feel good.


#2

@fuuyutsuki: I know it's truly annoying and make you question yourself but it happens.
Maybe it's your browser or an issue with the program used to run our codes, who knows?

What I'd suggest you to do in those cases: since you're working with JS, try finding online IDE such as repl.it and test your code.
There you'll be able to see at which line of your code you're commiting a mistake, if you're actualling doing such thing.

If everything is okay there but still doesn't work here on Codecademy, try refreshing your browser or trying on another one.
If it still doesn't work, let Codecademy's staff know about it and they'll do their best to help you out.

Those moments are perfect to test if you'll quit easily or not.
Had the same issues while working with HTML and CSS, after several minutes a kind user pointed out a tag I forgot to write on my file.
It just made me become more aware of what I type and to not give up, even when I feel like punching my computer and throw it away.

Hope it helps you, keep coding! :sunny:


#3

this may be a long shot, but try deleting your { and } and re-typing them.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.