Checking euquality of two words from two different array, two different words are equal :O

let check= (arr1, arr2)=> {

                // console.log(arr1);


                found= 0;

                for (let i= 0; i<arr1.length; i++){

                  for(let j= 0; j<arr2.length; j++){

                    // console.log(`${arr1[i]} ${arr2[j]}`);

                    if (arr1[i] === arr2[j])



                      found+= 1

                      if (found == 2)

                        return true;






                return false;


thats such a nonsense.
one time it worked as intended
and now… not… never… i dont understand why.

iam using firefox, the newest.

i also have this error:
Error: NetworkError when attempting to fetch resource.

not sure if thats related.

also for some reason live server doesn’t always loads the code to the browser.


found the solution : D

its the second debugger word, its outside the scope, making the condition scope not work.

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 (’).

I’m not really sure if I understand what this is trying to do. If your goal is to see if there are two common elements in the arrays (in other words, there intersection is two or more) then this seems to work for me. I have a pen here.

thank you, i figured out the problem.
its the second debugger word, messing up the condition scoping.

Yeah, that makes sense. That’s reason #37 why it is good to get in the habit of writing code in a neat and orderly fashion. In the long run it just saves you so much time and hassle.

1 Like

what you mean?

is there a better way to do it by the way? was thinking for of, but it didn’t work out.

also do you know why sometimes the code doesn’t load to the browser?
like… the page loads ofc but at the dev tools there is no code to debug.

I assume @kevinSmith is talking about your lack of proper code formatting.

I would highly suggest following normal code formatting conventions and using a code formatter like Prettier (most online editors have an auto-format as well).

That is impossible to answer without seeing the code, but it’s likely caused by some error in the code, like syntax errors, etc.

1 Like

Yeah, what lasjorg said. And if you’re developing locally, setting up a good linter and prettier will just get you in the habit. It drives you crazy at first but eventually just becomes habit.

i dont know… i dont like those auto formaters.

At the very least, it is polite to format your code when asking for help. This makes it far, far easier for others to read your work.

I agree that they can be annoying and take some getting used to.


I highly recommend using a formatter. They help you get used to standard conventions and they help you see and catch bugs.

The point is that you learn to format the way they do, by some industry standard, so it just becomes habit. It’s a good thing.

1 Like