I want to use the input_index to represent the array number of a certain object but it fails. I want to make the code shorter.
I have this code and the js array has different objects so i created a function such that when a user has finished inputing the value and clicks search yhe corresponding objects are triggered but Each id in <p> id in html has its own ''if'' statement and this makes the code longer and at some point if am am to continue i might forget some part of the code . I need some help if there is a way of using loops or anything else such that i dont need to write many ''if else '' statements I will be glad if soneone helps me because i have a code am writting and it uses this syntax; Part of it looks like this const input_text=[ { User_input:'book', bg_image:'image1 Book url', path:'page path' }, { User_input :"gold", bg_image :"image2 Gold url", path:"page2 path" }, { User_input :"car", bg_image :"image3 Car url", path:"page3 path" } ]; Here is the code https://code.sololearn.com/WDs0lO76xrh9/?ref=app