Please tell me why my variables are still 0

Please tell me why my variables are still 0...

Because syntax error

...

I don't know JS, but
>});

No OP, but no, fuck you. Last I checked, this board is called "random," not exclusively "porn and raffruse bullshit."

The problem lies in your "if" statement. What is the value of navigator.geolocation? Is it boolean, and more specifically a "true" boolean? If not, that entire section doesn't run, and your variables retain global values of 0.

Line 6 has an open Bracket you didn't close in line 14

because you don't know basic syntax like opening and closin scopes.

There is other code that is being executed underneath and it is closed properly after that.
That's what i thought, but it is being run, hence you can see that the test div has received the lat and long parameters on the right.

Judging by his indenting, he closed it further down the page.

read about async functions, everything else here is trash

It says right there the resource failed to load.

Would you mind printing position.coords.latitude/longitude after setting them, just to make sure they reach the proper value?

Thanks, i'll have a look.
That's not the issue, the lat and long has already been successfully used (in the right of the image) but it's not assigning to the variable.

Printed variables are out of scope. Now get back to Stack overflow and off b

Exactly; methinks it's not reaching the page and so those functions are responding zero. He should print them to see what values are produced from the request.

the definition of the lat and long are only defined local at the pos.coords. Put the console log below line 12

It might be because where you set the variables is a callback. So there's always the possibility that the code is running async

Because you cant code for shit faggot. Go read a tutorial or something.

That works, but how would i access those variables outside of that?

>No OP, but no, fuck you
Ok, ignore the technology board for this technology question.
I'm sure a bunch of random people on Sup Forums of all places will know much more.
Also the idea of Sup Forums is that it's a board for things that don't already have a board.
I bet you believe you're truly anonymous as well.

Cause navigator.geolocation equals to false

It doesn't you cuck

>Javascript

everything in javascript lives in the window object so you can define latitude window.latitude and outside of the function, the variable can be accessed by just latitude, however, this is bad practice since the global namespace of js is horribly crowded. it's better practice to just return them from a function. you could even define it inside the first functino. that's essentially how js gets away without classes

...

Line 13

Fucking delete );

GetCurrentPosition(...) is a callback function that doesnt run right away.
Put the console.log inside it and it should work

closing bracket is outside the picture, thats why console.log is indent.

god this is really Sup Forums

that's why I told op to read about async functions ages ago. but none gets it.

your script keeps running independently from getcurrentpositions. thats why you get 0 as output.

Whats with the "script injected" part? Do we have to report you to the code police?

must be one of those anonymous hacker