Get Geolocation Data

Tell us what’s happening:
The task is passed. BUT: there wasn’t any coords on virtual phone screen and, if I try this code in browser separately, it shows “Uncaught ReferenceError: $ is not defined”. what I’m doing wrong?

Your code so far

  // Only change code below this line.
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
  // Only change code above this line.
<div id = "data">
  <h4>You are here:</h4>
  #data {
    color: red;

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36.

Link to the challenge:

It is normal that your task passed, because the code you typed in was correct.

However, if you want to get the coordinates and display them, you have to do it outside the challenge, for example in a Codepen.

If you try this code in the Codepen, keep in mind that the $ symbol comes from jQuery, and that you have to include this using a script tag:

<script src=""></script>

If you have done everything correctly, you will get a prompt, which looks like this in Chrome:


Finally, you have to allow it and it will display your location.

thank you very much for your help! it helped me!

I’m glad I was able to help.

If you have any further questions, don’t hesitate to ask!