I'm very new but I've completed some courses on freecodecamp. Say that I make an object about cars. I want the webpage user to be able to write "Ford Mustang" and after this all the information stored in the object fordMustang pops up for the user to read.
I've tried some different tactics but cant get it to work. Here is the code I have written,
<label for="navn">
<input type="text" id="field" class="field" name="navn">
<input type="submit" value="send" id="send" class="send">
</label> <p id="par"> </p>
let fordMustang = {
producer: "Ford",
type: "Mustang",
engine: "v8",
horsePower: 300 }
const inputField = document.querySelector(".field");
const press = document.querySelector("#send");
const para = document.querySelector("#par");
function objScan() {
const word = String(inputField.value);
if (word == "Ford Mustang") {
para.textContent = fordMustang;
}
else {
para.textContent = "Not recognized"
}
}
press.addEventListener("click", objScan);