Skip to content
Advertisement

If else not working as intended, is there something wrong with my logic?

I’m trying to loop through an array and if there are any matching elements, it should push true to a new array else return false.

JavaScript

By this logic, wordPerformance should return

JavaScript

however, it is returning

JavaScript

Maybe there is something I’m not seeing?

Advertisement

Answer

You have to first split the wordsIncorrect string the same way you did it with the wordsReviewed so it does compare whith the item and not include strings which have something at the end like matching “cat” with “cattle”

This is the fixed example

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement