I feel like a total newb for asking this question, but I’ve googled and searched the forum for hours and can’t figure out the problem. So here it is:
I want to make a simple game using the Magic 8 Ball project as a base. So, I started by copying what I used to make the project into VS Code. I haven’t used JS in VS code yet, just HTML and CSS. I tried to run the program in VS code through the integrated terminal and I get the error message below:
I can’t figure out what I’m doing wrong. How do I get the code to run in VS Code? It ran perfectly here in the project workspace. So, I’m not sure if it’s my laptop, VS Code, or I’m just trying to do something I’m not supposed to because I’m new at this. Any advice is appreciated.
(It’s a bit like how there’s little variations in how you do things in SQL on a Microsoft DB or an Oracle one… unless they’ve both standardised themselves since I last went near Oracle…)
The error is pretty clear on the matter; you’re missing a semi-colon at line 1, char 5.
If you’d also posted the code, we’d be able to check whether the error is right or not.
I understand where the error is and how to fix it. That was actually the first thing I tried, but then it gave me about 6 more before I stopped trying and when I looked back at the code, it didn’t make sense anymore. Here’s the code without the changes:
eightBall = “It is certain”;
eightBall = “It is decidedly so”;
eightBall = “Reply hazy try again”;
eightBall = “Cannot predict now”;
eightBall = “Do not count on it”;
eightBall = “My sources say no”;
eightBall = “Outlook not so good”;
eightBall = “Signs point to yes”;
eightBall = “When Pigs Fly”;
I don’t do any dev stuff on my Windows machine, purely because there’s fewer hoops to jump through on Linux to get everything I need working, so I’m probably not the best guinea pig for this.
If you use Chrome as your preferred browser, there is an extension available for Visual Studio Code called Debugger for Chrome. It basically lets you write the code in VS Code, but run it (and debug it) directly in Chrome using their JS interpreter.
If you’ve got Chrome installed, that extension might make it easier for you to write and run your JS locally.
I think windows users easily get the impression that a text editor is the operating system, is the thing responsible for running code.
It’s a text editor. Types letters, saves files. Doesn’t run programs.
Imagine if every program had a built in web browser just so you could google without alt tabbing.
The same principle applies to programming in general, if a problem is multiple subproblems and you try to solve them all at once in the same place then you’ll get a complicated entangled piece of code, but if you solve one subproblem at a time in isolation from the rest then you’ll have several simple pieces.
The equivalent of double clicking a text file, at which point “file association” (such a silly thing) takes over.
If you ever peek at windows processes you might notice shost.exe using cpu for seemingly no reason (could be anything), well it’s that blob that got invoked.
Yeah, I was being a dumb dumb. VSC has so many features I got it in my head I could do anything on it smh. I figured out how to use the chrome debugger, which is helpful, but it wasn’t what I was originally trying to do. I thought I could use the terminal in VSC like the console in codecademy workspace . I’m now using jsbin as I work through the JS side of my little game to run it in their console like I did here. Then running the debugger in VSC to make sure all the pieces fit together properly. So far so good
It def was, before I created this post I was looking into what that was and trying to see if I could change it or something. I was doing the most smh. It worked out though, and thanks again to everyone for the help!
You’re not entirely wrong, but nearly all of it will be a wrapper around some other tool. vsc’s representation of those tools is incomplete so things can go wrong that vsc doesn’t deal with or you may need things that aren’t part of the representation - and then you have to deal with them directly without any help. It’s also not really vsc doing it, but whatever plugin you happen to be using.