Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!DOCTYPE html>
    <title>McDuck's Local offers</title>

<h1> McDuck's Local Offers</h1>
<!--1. Create a HTML button that when clicked calls the JavaScript getLocation() function -->

<!--Two containers, called divs, used to show messages to user -->

<div id="geodisplay"></div>
<div id="effect"></div>



5. Once your app is working change the text colors to be McDuck's colors

body {
    text-align: center;
    background: white;


h1, h2, h3, p {
    font-family: Sans-Serif;
    color: black;

p {
    font-size: 1em;


                function getLocation() {
	if (navigator.geolocation){

function showLocation(position){

// 2. Hardcode your store location on line 12 and 13, and update the  comment on line 10 to reflect your McDuck's restaurant address
//  Nik's apt @ Perry & W 4th St (change to your restaurant location)

var mcduckslat=40.735383;
var mcduckslon=-74.002994;

// current location
var currentpositionlat=position.coords.latitude;
var currentpositionlon=position.coords.longitude;

// calculate the distance between current location & McDuck's location  
var distance=getDistanceFromLatLonInMiles(mcduckslat, mcduckslon,currentpositionlat,currentpositionlon);
// 3. Display the distance using a JavaScript alert(). Comment out the line with two // after you confirm the distance is correct.

// 4. Create if-else trigger using an alert()

// Displays the location using .innerHTML method and the lat & long coordinates for your current location
document.getElementById("geodisplay").innerHTML="Latitude: " + currentpositionlat + "<br>Longitude: " + currentpositionlon;
// Haversine distance formula
 function getDistanceFromLatLonInMiles(lat1,lon1,lat2,lon2) {
  var R = 6371; // Radius of the earth in km
  var dLat = deg2rad(lat2-lat1);  // deg2rad below
  var dLon = deg2rad(lon2-lon1); 
  var a = 
    Math.sin(dLat/2) * Math.sin(dLat/2) +
    Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * 
    Math.sin(dLon/2) * Math.sin(dLon/2); 
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  var d = R * c * 0.621371; // Distance in miles
  return d;

 function deg2rad(deg) {
  return deg * (Math.PI/180)