Please Fix This Code. | Sololearn: Learn to code for FREE!

+11

Please Fix This Code.

If is Add a word in input option , like a " Apple , Book , Scool " etc. Its show me , not found word, If i add a last word " Class" , its show me word meaning.... How its work fine ? https://code.sololearn.com/W8E9E5AkXhRO/?ref=app

6/22/2021 6:21:17 AM

Ayesha Noor

14 Answers

New Answer

+18

function Mean(){ //input value var text=document.getElementById("word").value.toLowerCase(); var total_=database.length; for(i=0;i<total_;i++){ var db= database[i]["word"].toLowerCase(); if(text===db){ var got_=database[i]["meaning"]; result.innerHTML=`<center>Word: <span id="result_word">${text}</span></center> <center>Meaning :<b id="meaning">${got_}</b></center>`; break; } else{ result.innerHTML ="<center>Not Found</center>"; } } return false; }

+1

function Mean(){ var input= document.getElementById("word").value.toLowerCase(); var total_=database.length; for(i=0;i<total_;i++){ var db= database[i]["word"].toLowerCase(); if(input.trim()===db.trim()){ var got_=database[i]["meaning"]; result.innerHtml=''; result.innerHTML=`<center>Word: <span id="result_word">${db}</span></center> <center>Meaning :<b id="meaning">${got_}</b></center>`; return true; } } result.innerHTML ="<center>Not Found</center>"; return false; }

+1

const database=[ {"word":"Apple","meaning":"پھل"}, {"word":"Book","meaning":"کتاب"}, {"word":"School","meaning":"سکول"}, {"word":"Class","meaning":"جماعت"} ] function Mean(){ var input= document.getElementById("word").value.toLowerCase(); var total_=database.length; for(i=0;i<total_;i++){ var db= database[i]["word"].toLowerCase(); if(input.trim()===db.trim()){ var got_=database[i]["meaning"]; result.innerHtml=''; result.innerHTML=`<center>Word: <span id="result_word">${db}</span></center> <center>Meaning :<b id="meaning">${got_}</b></center>`; return false; } } result.innerHTML ="<center>Not Found</center>"; return false; }

0

I think here last return statement false is spelling mistaked by falsd. Its the fault.

0

Js: const database=[ {"word":"Apple","meaning":"پھل"}, {"word":"Book","meaning":"کتاب"}, {"word":"School","meaning":"سکول"}, {"word":"Class","meaning":"جماعت"} ] function Mean(){ var input= document.getElementById("word").value.toLowerCase(); var total_=database.length; for(i=0;i<total_;i++){ var db= database[i]["word"].toLowerCase(); if(input.trim()===db.trim()){ var got_=database[i]["meaning"]; result.innerHtml=''; result.innerHTML=`<center>Word: <span id="result_word">${db}</span></center> <center>Meaning :<b id="meaning">${got_}</b></center>`; return false; } } result.innerHTML ="<center>Not Found</center>"; return false; } falsd = false

0

The code is working Fine!

0

I have resolved your error, You can view it here https://code.sololearn.com/WBiOr2TO5koE/?ref=app

-1

-9