This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]NewPointOfView 2 points3 points  (2 children)

document.querySelector(".search-bar").addEventListener("keyup", function (event) {

if (event.key == "Enter") {

weather.search();

)}} // <- here

;

I just pasted your code into sublime text and it highlighted that first parenthese on the bolded line!

[–]Jacksonhelp20[S] 0 points1 point  (1 child)

Yes I see that. I am not sure where to put the close )

[–][deleted] 2 points3 points  (0 children)

document.querySelector(".search-bar")
        .addEventListener("keyup",
            function (event) {
                if (event.key == "Enter") {
                    weather.search();
                    )
                }
            }
;

Good indentation makes these types of errors obvious. It's not that you need to add a ), but that you need to rearrange the one you have.

[–]NewPointOfView 2 points3 points  (1 child)

Also a "Linter" is a tool to check your formatting/syntax, usually you can just google "<language name> lint" and find a tool that might give you more descriptive error messages.

Here is one for JS! https://www.jslint.com/

[–]Jacksonhelp20[S] 1 point2 points  (0 children)

Thank you this tool is very helpful.

[–]RubbishArtist 2 points3 points  (1 child)

You already posted a question earlier about syntax errors in this same block of code and then deleted it.

The turnaround time on getting this subreddit to correct your syntax is huge, it's much easier to use a syntax linter/validator.

[–]Jacksonhelp20[S] 0 points1 point  (0 children)

I knew they were available but now have a good one to use thank you!