Created
May 23, 2024 18:53
-
-
Save 7daysofrain/32b0a2d6bfeaa8e7d91341710a6430c9 to your computer and use it in GitHub Desktop.
temperaturas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lat = 36.527061; | |
const lng = -6.288596; | |
const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lng}¤t=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m`; | |
function mostrar(tiempo) { | |
//console.log(tiempo.current.temperature_2m) | |
//console.log(tiempo.hourly.time[68]) | |
//console.log(tiempo.hourly.temperature_2m[68]) | |
calcularTemperaturaMedia(tiempo, 0); | |
} | |
function calcularTemperaturaMedia(tiempo, dia) { | |
let temperaturas = tiempo.hourly.temperature_2m; | |
temperaturas = temperaturas.filter( (temp, index) => { | |
if(index >= (dia * 24) && index < ((dia+1) * 24)) { | |
return true; | |
} else { | |
return false; | |
} | |
}) | |
let media = 0; | |
temperaturas.forEach( temp => { | |
media += temp; | |
}) | |
console.log(media/24) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment