Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fa35bb3

Browse files
committed
add condition
1 parent ae48b84 commit fa35bb3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Source-Code/WeatherApp/script.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const apiKey = "e3a46268fdc2475cb63214712240202";
44
const cityName = document.getElementById("city-name");
55
const dateTime = document.getElementById("date-time");
66
const condition = document.getElementById("condition");
7+
const condition2 = document.getElementById("condition2");
78
const temp = document.getElementById("temp");
89
const humidity = document.getElementById("humidity");
910
const country = document.getElementById("country");
@@ -28,6 +29,10 @@ const updateWeatherInfo = (result) => {
2829
country.innerText = `${result.location.country}`;
2930
dateTime.innerText = `${result.location.localtime}`;
3031
temp.innerText = `${result.current.temp_c} °C`;
32+
humidity.innerText = `${result.current.humidity} %`;
33+
condition.innerText = `${result.current.condition.text}`;
34+
condition2.innerText = `${result.current.condition.text}`;
35+
icon.src = `${result.current.condition.icon}`; // Set the src attribute of the img tag with id "icon"
3136
};
3237
const getData = async (cityName) =>
3338
fetchData(
@@ -57,6 +62,7 @@ btn.addEventListener("click", async () => {
5762
const { value } = input;
5863
const result = await getData(value);
5964
updateWeatherInfo(result);
65+
console.log(result);
6066
} catch (error) {
6167
cityName.innerText = "Error to fetch weather";
6268
}

0 commit comments

Comments
 (0)