-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
47 lines (44 loc) · 1.14 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { useState } from "react";
import "./styles.css";
export default function App() {
let emojiDictionary = {
"🍕": "Pizza",
"🍔": "Burger",
"🍟": "Chips",
"🌭": "Hot Dog",
"🍿": "PopCorn"
};
let emojisWeKnow = Object.keys(emojiDictionary);
let [meaning, setMeaning] = useState("");
function emojiInputHandler(event) {
let userInput = event.target.value;
var meaning = emojiDictionary[userInput];
if (meaning === undefined) {
meaning = "No idea";
}
setMeaning(meaning);
}
function emojiClickHandler(emoji) {
var meaning = emojiDictionary[emoji];
setMeaning(meaning);
}
return (
<div className="App">
<h1>Food Emoji Identifier </h1>
<input onChange={emojiInputHandler}></input>
<h2>{meaning}</h2>
<h3>Emojis we know</h3>
{emojisWeKnow.map(function (emoji) {
return (
<span
onClick={() => emojiClickHandler(emoji)}
style={{ fontSize: "2.2rem", padding: "1rem", cursor: "pointer" }}
keys={emoji}
>
{emoji}
</span>
);
})}
</div>
);
}