Skip to content

Commit

Permalink
fix issue #4 - units not displayed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
nextdoorpanda committed Sep 11, 2023
1 parent 6676978 commit 0cfd8f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions assets/js/ci-openweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
const weatherIconCode = weatherData.list[0].weather[0].icon;
const weatherIcon = `http://openweathermap.org/img/w/${weatherIconCode}.png`;
const weatherTemperatureValue = `${parseInt(weatherData.list[0].main.temp)}`;
let weatherTemperatureDegree = 'K';
weatherOptionsValues.unit = 'metric' ? weatherTemperatureDegree = '°C' : weatherTemperatureDegree = '°F';
const weatherTemperature = `${weatherTemperatureValue}${weatherTemperatureDegree}`;
const weatherTemperatureDegrees = [{'standard': 'K'}, {'metric': 'C'}, {'imperial': 'F'}];
const weatherTemperatureDegree = weatherTemperatureDegrees
.filter( obj => weatherOptionsValues.unit in obj)
.map(obj => obj[weatherOptionsValues.unit]);
const weatherTemperature = `${weatherTemperatureValue}°${weatherTemperatureDegree}`;

const outputDiv = document.querySelectorAll('.weather-output');
outputDiv.forEach( item => {
Expand Down

0 comments on commit 0cfd8f9

Please sign in to comment.