-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (38 loc) · 1.93 KB
/
script.js
File metadata and controls
45 lines (38 loc) · 1.93 KB
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
// document.addEventListener("DOMContentLoaded", function(){
// const searchInput = document.getElementById('searchInput');
// const searchBtn = document.getElementById('searchBtn');
// const words = document.getElementById('word');
// const definitions = document.getElementById('definition');
// const examples = document.getElementById('example');
// const synonym = document.getElementById('synonyms');
// const dictionary = async (word) => {
// try {
// const response = await fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`);
// const data = await response.json();
// words.textContent = data[0].word;
// const definition = data[0].meanings[0].definitions[0].definition;
// // document.getElementById("definition").innerText = definition;
// definitions.textContent = definition;
// // const example = data[0].meanings[0].definitions[0].definition[0].example;
// if (data[0].meanings[0].definitions[1] && data[0].meanings[0].definitions[1].example) {
// examples.textContent = data[0].meanings[0].definitions[1].example;
// } else {
// // Check other potential locations for an example
// if (data[0].meanings[0].definitions[0].example) {
// examples.textContent = data[0].meanings[0].definitions[0].example;
// } else {
// examples.textContent = "No example found.";
// }
// }
// const synonyms = data[0].meanings[0].synonyms;
// synonym.textContent = synonyms.join(', ');
// console.log(data);
// } catch (error) {
// console.error(error);
// }
// };
// searchBtn.addEventListener("click", (e) => {
// e.preventDefault();
// dictionary(searchInput.value);
// });
// });