I would like to create a function that has as parameters the name of an array and any string. The goal is that just by entering the names of both things, the function logue the index of the item, if it exists within the array (no need to use quotes when specifying the item when I call the function) . Here I leave the code of what more or less I wanted to achieve
function findId (array, item) {
let stringedItem = String(item)
let index = array.indexOf(stringedItem)
console.log(index)
}
const array1 = ['objeto1', 'objeto2', 'objeto3'];
findId(array1, objeto3)
pd. I am new with the programming, I say it in case this doubt is very basic or something like that haha. Thanks to whoever can answer me:) ... Oh, and I found string()
in an online blog, I honestly do not know exactly what he does, I only understand that he can convert everything to a string