Is the Pet in the List?
easyQuestion 102The includes method returns true or false depending on whether an array contains a value, and indexOf returns the position of a value (or -1 if it is not there). You are given an array of pets. Print whether the array includes "dog", then whether it includes "rabbit", then print the index of "fish" - each on its own line.
Expected output
true false 2
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.