Skip to content

Commit

Permalink
fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
favy-codez committed Aug 21, 2023
1 parent f39989f commit b7ee965
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</head>
<body>
<div class="container">
<h1 class="heading">Englist Dictionary</h1>
<h1 class="heading">English Dictionary</h1>
<input type="text" name="" class="input" id="input" placeholder="Search a word">
<p class="info-text" id="info-text">Type a word and press enter</p>
<div class="meaning-container" id="meaning-cntainer">
Expand Down
17 changes: 17 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const input = document.getElementById("input");

async function fetchAPI(word){
const url = `https://api.dictionaryapi.dev/api/v2/entries/en/${word}`
const result = await fetch(url).then((res)=>res.json())
console.log(result);
}

input.addEventListener("keyup", (e)=> {
// console.log anything we enter
// console.log(e.target.value);
// shows the key e.g enter, backspace
// console.log(e.key);
if(e.target.value && e.key === "Enter"){
fetchAPI(e.target.value)
}
})
18 changes: 18 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,22 @@ body{
max-width: 450px;
text-align: center;
font-size: 18px;
font-weight: 500;
}

.heading{
font-size: 28px;
}
.input{
height: 53px;
width: 300px;
background-color: rgba(255, 255, 255, .6);
border-color: rgba(255, 255, 255, .4);
font-size: 16px;
padding: 0px 42px;
border-radius: 5px;
}

.meaning-container{
display: none;
}

0 comments on commit b7ee965

Please sign in to comment.