Code does not work


sooooo here is the problem. My code works in the codecademy window, but does not work on my laptop.
I mean, I write the code in the NotePad, save it, open the container and nothing happens.

I´m really new at this and have no clue, what it could be.
Ideas anyone??

here is the code. I´ve also tried it with alert(console.log)


Pretty sure the problem is you don’t have the file saved as (example.js). The .js tells it that it needs to be read as JavaScript. Try putting the .js at the end of your file name. If it doesn’t work, let me know.

hi, thank you for your answer.

I actually did.
and something like this does work

var konto = 150000;
if ( konto >= 0 ) {
alert(“You have money!”);
if ( konto > 10000) {
alert (“You have a lot of money!”);

Use an html file with the js file in the head.

    <script src="YourFile.js"></script>

Then open the html file in the browser. This assumes the .html file and YourFile.js are in the same directory/folder.

Get rid of those semicolons after the parentheses, and put them after the closing curly brackets instead

if( konto > 10000) {
alert(“You have a lot of money!”)

the second peace of code works both ways, the 1st with console.log doesn’t

Can I see all the code? Sometimes something really little can cause stuff not to work, and it can be just about anywhere


this was the whole code from the excercise

it works in codecademy, but not in the browser.
for example, if I write console.log(3.5+28); nothing happens

but if I write
var a = 3.5;
var b = 28;
var d = a + b; {

I have my 32.5 answer. So I just asked myself, what was the problem with the first variant

I think, I’ve figured it out
if I write alert instead of console.lög, it works

even in this code

let a = 'a'
let b = 'b'
if (a < b) { // true
  console.log(a + ' is less than ' + b)
} else if (a > b) {
  console.log(a + ' is greater than ' + b)
} else {
  console.log(a + ' and ' + b + ' are equal.')

it does not work with console.log and does with alert. No idea why

console.log() does not write to the document, so it won’t work in browser. If you inspect your browser window, the go to console, you should see the output from the console.log() statements.
EDIT: I’m assuming you’re trying to run this in a browser window?


Javascript can only be used in the browser. Just to point out, the “alert()” function makes a GUI popup on the browser with your custom text whereas “console.log()” function is treated like the “print()” function of which is mainly used for debugging and can only be accessed when you inspect element.