The same problem, it doesn't work! Hello! I have this code in html, css and javascript. The project is to write a code that we have a link for a database and there are many words in this database, the user should enter a word and if the word is present so ok, if not we have to help him to find a word. I write this code but if i write the word nothing happen. Thank you! The code html: My Project Welcome ! Please enter a word : Chercher The code css: body { font-family: sans-serif; background-color: #f0f0f0; } h1 { text-align: center; margin-top: 50px; } p { margin: 10px 0; } input[type="text"] { padding: 10px; font-size: 16px; border: none; border-radius: 4px; box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2); margin-right: 10px; } button { padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: #007bff; color: #fff; cursor: pointer; box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2); } button:hover { background-color: #0069d9; } #error { color: red; margin-top: 10px; } #success { color: green; margin-top: 10px; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

The same problem, it doesn't work!

Hello!
I have this code in html, css and javascript.
The project is to write a code that we have a link for a database and there are many words in this database, the user should enter a word and if the word is present so ok, if not we have to help him to find a word.
I write this code but if i write the word nothing happen.
Thank you!
The code html:

<!DOCTYPE html>
<html>
<head>
    <title>My Project</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>Welcome !</h1>
    <p>Please enter a word :</p>
    <input type="text" id="input-mot">
    <button onclick="chercherMot()">Chercher</button>

    <script>
        // Define the URL of the dictionary
        const dictionaryUrl = "https://raw.githubusercontent.com/difabiolorenzo/motusJS/master/src/js/dictionary/words.js";
       
        // Load the dictionary file using fetch
        fetch(dictionaryUrl)
        .then(response => response.json())
        .then(words => {

        // Define a function to check if a word is present in the dictionary
        function checkWord(word) {
        return words.includes(word.toLowerCase());
        }
       
        // Prompt the user to enter a word and check if it's in the dictionary
        let userWord = prompt("Enter a word:");
        if (checkWord(userWord)) {
        console.log("The word is present in the dictionary.");
        } else {
        // If the word isn't in the dictionary, provide suggestions
        console.log("The word isn't present in the dictionary.");
        console.log("Here are some similar words:");
        words.filter(word => word.includes(userWord.toLowerCase().slice(0, 2)))
        .forEach(word => console.log(word));
        }
        })
        .catch(error => {
        console.error("Error loading dictionary:", error);
        });
    </script>
   
</body>
</html>
 
The code css:
body {
  font-family: sans-serif;
  background-color: #f0f0f0;
}

h1 {
  text-align: center;
  margin-top: 50px;
}

p {
  margin: 10px 0;
}

input[type="text"] {
  padding: 10px;
  font-size: 16px;
  border: none;
  border-radius: 4px;
  box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
  margin-right: 10px;
}

button {
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  border-radius: 4px;
  background-color: #007bff;
  color: #fff;
  cursor: pointer;
  box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
}

button:hover {
  background-color: #0069d9;
}

#error {
  color: red;
  margin-top: 10px;
}

#success {
  color: green;
  margin-top: 10px;
}
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Form and its Elements
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education