Hello, I’m working with a JS problem that seemed pretty basic to me on the surface, but I’m having trouble with it and would like some advice about how to proceed.

So I’ll give you the set-up and what I’ve written so far as well as where I think I’m wrong. Please clear up any misconceptions or incorrect logic. Thank you!

*You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its citizens with a Walk Generating App on their phones – everytime you press the button it sends you an array of one-letter strings representing directions to walk (eg. [‘n’, ‘s’, ‘w’, ‘e’]). You always walk only a single block in a direction and you know it takes you one minute to traverse one city block, so create a function that will return true if the walk the app gives you will take you exactly ten minutes (you don’t want to be early or late!) and will, of course, return you to your starting point. Return false otherwise.*

*> Note : you will always receive a valid array containing a random assortment of direction letters (‘n’, ‘s’, ‘e’, or ‘w’ only). It will never give you an empty array (that’s not a walk, that’s standing still!).*

`function isValidWalk(walk) {`

for(var i = 0;walk[i].length === 10000;i++){

for(var j = 0;walk[j].length === 10000;j++){

if(walk[i].length === 10000 && walk[j].length === 10000) {

return true;

} else {

return false;

}

}

}

So, my basic idea was to loop through the way forward[i] and the way back[j] and assign those the same numerical value and if both were true, then the function would return true.

I think the problem might be in two sections:

1.Perhaps I am using the variable i and j incorrectly. Perhaps I should be using them together in some way.

2.Perhaps I should not be using length with i and j (I’m not sure exactly why I think this, but it seems like the only weak spot to me right now.

Thank you for your time.

(Obviously I’m at work on a CodeWars project. Much appreciation for any feedback you could provide.)