Created
November 16, 2019 16:56
-
-
Save 01Clarian/cdebd876c68825fd9920e63fc16c2cb8 to your computer and use it in GitHub Desktop.
Weather matching Keyword Algorithm
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}) => { | |
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])) { | |
console.log(weatherDescription[i], ': we have a match') | |
} | |
} | |
console.log(keyWords) | |
console.log(weatherDescription) | |
} | |
return ( | |
<div> | |
{city && country && <p>{city}, {country}</p>} | |
{temperature && <p>{temperature} °F</p>} | |
{description && <p> Conditions: {description}</p>} | |
{error && <p>{error}</p>} | |
</div> | |
) | |
} | |
export default Weather; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment