FCC Local Weather

Developer
Size
2,076 Kb
Views
10,120

How do I make an fcc local weather?

What is a fcc local weather? How do you make a fcc local weather? This script and codes were developed by Victoria on 02 December 2022, Friday.

FCC Local Weather Previews

FCC Local Weather - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>FCC Local Weather</title>
</head>
<body> <button class="convert">°F / °C </button>
<div> <div class="current-city"></div> <span class="temperature"></span> <span class="measure"></span>
</div>
<img class="weather-img"/> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

FCC Local Weather - Script Codes JS Codes

const CELSIUM = 'Celsium';
const FAHRENHEIT = 'Fahrenheit';
const farCelSwitch = { 'C': 'F', 'F': 'C'
};
const farCelTitles = { 'C': CELSIUM, 'F': FAHRENHEIT
};
const setMeasure = m => { $('.measure').empty().append(farCelTitles[m]); $('.measure').data('measure', m);
};
const convert = () => { const measure = $('.measure').data('measure'); const currentTemp = $('.temperature').text(); const _conv = (value, measurement) => { return measurement === 'F' ? ((value - 32) * 5/9) : (value * 9/5 + 32); }; const printConvert = (value, measurement) => { const newMeasurement = farCelSwitch[measurement]; setMeasure(newMeasurement); $('.temperature').empty().append(_conv(value, newMeasurement).toFixed(2)); } printConvert(currentTemp, measure);
};
$('.convert').click(convert);
var weatherApp = () => { var weatherRequest = (pos) => { var lon = pos.coords.longitude; var lat = pos.coords.latitude; var url ='http://api.openweathermap.org/data/2.5/weather?lat=' + lat + '&lon=' + lon + '&units=metric' +'&APPID=038e9ad1a5f02051a3db265045994d1c'; $.get(url, (data) => { $('.current-city').append(data.name); $('.temperature').append(data.main.temp); setMeasure('C'); $('.weather-img').attr({ src: 'http://openweathermap.org/img/w/' + data.weather[0].icon + '.png' }); }) } navigator.geolocation.getCurrentPosition(weatherRequest);
};
$(weatherApp);
FCC Local Weather - Script Codes
FCC Local Weather - Script Codes
Home Page Home
Developer Victoria
Username Enieste
Uploaded December 02, 2022
Rating 3
Size 2,076 Kb
Views 10,120
Do you need developer help for FCC Local Weather?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Victoria (Enieste) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!