Solution doesn't work: User's position within the data div element

Tell us what’s happening:
Hello everyone!

When I submit my code, it always returns this message: “You should display the user’s position within the data element.”

Well, I’m seeing the user’s position in the screen and I used the getElementById('data') to access the data element.

So what am I doing wrong?

PS.: In this GitHub issue, people already had the same problem in the past

Your code so far

if(navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
      .innerHTML = 
        "latitude: " + position.coords.latitude +
        "<br>longitude: " + position.coords.longitude
<h4>You are here:</h4>
<div id="data">


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Get Geolocation Data to Find A User’s GPS Coordinates

Link to the challenge:

1 Like


The problem seems to be that your code is not on a single line, but the validator expects a single line.

And don’t forget the semicolon at the end of the line (I know it’s not required for JavaScript in general, but sometimes the validator is too strict :stuck_out_tongue:).

1 Like

Thank you skaparate! It worked here :smiley:

About the semicolon, you’re right. It’s a simple thing we don’t pay attention now, but may cause problems in the future. I’ll be more carefully

1 Like