Please help me dry run this

test= ["hey"];

if (target.indexOf(test[i]) < 0) {
return false;
else { return true; }

I have 2 arrays and I want to check if their strings match with each other. I am having problem with understanding this. how it is going to check the condition?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

You cannot return outside of a function , and attempting to do so will throw a syntax error.

I am a bit confused about what you are asking, but the method indexOf either returns the index of a value that is strictly equal to the given argument or it returns -1 in which case you can conclude that no such value exists within the array.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.