JScript Errors with console.log


Hey ppl. I have looked everywhere on the internet and haven’t found an answer to my simple question. I’m trying to write some javascript code and have it print to the command prompt window on my computer (windows 7). I’m using Notepad++ and saving it as a .js file. When I run the code, it says

‘Script: C:\Users\me\Desktop\test.js
Line: 6
Char: 1
Error: Object expected
Code: 800A138F
Source: Microsoft JScript runtime error’

This is my code:

var test = true;

switch (test) {
case true:
console.log('yay it worked!');
case false :
console.log('aww. it didnt work.');
console.log('Invalid answer');

What do I replace console.log with? I asked a friend but he didn’t have time to explain. He said something about ‘write To(console)’ or something. Idk. Just trying to figure it out so I can test javascript outside of HTML or codecademy. Thanks in advance! -matthew


Script is the Microsoft dialect of the ECMAScript scripting language specification.

so you will need to google what you need for Jscript, which isn’t identical to javascript

if you want to run javascript, install nodeJS


So JScript and Javascript are different. what do I replace console.log with to print it to the terminal then?


well, there are not completely different:

i have no idea, never used Jscript, but this should be findable with a simple google search?

you need to make a choice: learn Jscript or switch to javascript

If you are going to use Jscript, you will need to learn it, in this process you should be able to find out what to use instead, maybe the whole switch statement is different? Maybe you can google already? I have no idea about Jscript.


Ok. I still haven’t found the answer. Maybe someone who knows JScript can reply? that would probably help


i think very few people here know Jscript, jscript seems to have a print function:



I tried that and I got the same Error as before


have you verified that switch even exist within Jscript? I think you are better of finding someone on stackoverflow who can help you with this, then here on the forum

it seem to exist:


but there isn’t a single example i can find, good documentation this language (not)


Yes. Switch works in JScript. JScript is a variant of JavaScript. So they are quite similar. Thanks for your help.


you should go to stackoverflow, better change to find someone who knows Jscript then here.


Ok. Sounds good. Thanks for your help.


why do you decide to use Jscript? its far less commonly used, why not install nodeJS and use JavaScript which is far more common?


I want to try and practice coding with the programs I have. I don’t want to get new ones just to test out things I know. I want to learn more and challenge myself.


You don’t have to get new ones? Js can be run in browser (which i assume you have installed :wink: ), and open a console window (build into the browser), there console.log() output is displayed, but you would need to create html file, but no new software needs to be installed

then you have Javascript (which has far better documentation and more information (Q&A on stackoverflow for example)), going for a more obscure dialect (Jscript) is a major sacrifice.


How do I open the command window in the browser?


This depends on the browser, you must be able to find this with google

you might be even able to code in there


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