← Back to Arrays
Question 102
Is the Pet in the List?
Is the Pet in the List?
The 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 — 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.