Check if an array includes a string.
Make a function called findStringInArray(array, itemToFind)
that looks at all entries in an array and compares it to a string one by one. If the string is found then it prints a message that says the string has been found.
Example
let array = ["Pheobe", "Chandler", "Ross", "Monica", "Rachel", "Joey"];
findStringInArray(array, "Chandler")
// Output in console => Found Chandler, its postion is 1
Go over the given array and do the following:
- Go over all the items in the array and compare them to the passed string
- If the passed has been found then print "Found {item that was searched}, its position is {its index}
- If it didn't find it, it says item has not been found.
- This should work with any strings array!
Good luck :D