I want to find a page url searching by an input. I have an object that contains keywords and urls. Then when press enter it will do a check, if the keywords are the same or exist, it will display the url, if not it will display not found.
So for example in the input I type “home”, when I enter it will display the url “/homepage” because the keywords are exist, if I type “contact” it will show not found because the keywords doesn’t exist.
I’ve made the code like below but why the map doesn’t work? can anyone help me?
$(document).ready(function(){
$("#searchKeywords").on("keypress", function(e){
if(e.which == 13){
const pageKeywords = {
"home" : "/homepage",
"about" : "/about-us"
}
pageKeywords.map((key,value) => {
console.log(key)
if($(this).val() == key){
console.log(value)
}else{
console.log('not found')
}
})
}
});
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="searchKeywords">