Created
November 16, 2019 17:04
-
-
Save 01Clarian/852f862c17174e8b5fee28a4af1e12a3 to your computer and use it in GitHub Desktop.
FInish Weather Keyword Search
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
import React from 'react' | |
const Weather = ({description, city, country, error, temperature}) => { | |
function matchValues () { | |
if(description) { | |
const weatherDescription = description.split(' ') | |
const keyWords = ['cloudy','clouds', 'cloud', 'overcast'] | |
for(let i = 0; i < weatherDescription.length; i++) { | |
if(keyWords.includes(weatherDescription[i])) { | |
return <img src='https://media.freestocktextures.com/cache/74/8b/748ba3fe5976d8b03219a64851d2790d.jpg' /> | |
} | |
} | |
}} | |
return ( | |
<div> | |
{city && country && <p>{city}, {country}</p>} | |
{temperature && <p>{temperature} °F</p>} | |
{description && <p> Conditions: {description}</p>} | |
{error && <p>{error}</p>} | |
{description && matchValues()} | |
</div> | |
) | |
} | |
export default Weather; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment