Challenge #17...help!


#1

I’m stuck and so far I have this:

function shipReport(){
var shipOrder = allShips().sort();
var finalShip = [shipOrder[0],shipOrder[shipOrder.length-1]];
return finalShip;

}

I also tried using the slice method but both time i get the “Your code ran but did not produce the correct result”.
It works on other editor tho…


#2

thats strange, i have the same and it works for me


#3

What does your allShips() function return?


#4

Have you resolved the issue, @klau?
I’ve implemented the same logic and it works for me.


#5

not yet, i’ve tried other approach too


#6

I just pasted your function into my setup and logged the following to the console:

[“B3”, “I5”]

As noted in a previous thread (challenge 17, issues), I passed the challenge with [ ‘C2’, ‘I5’ ] the first and last element of the array prior to the sort. Full array unsorted for reference is [“C2”, “B3”, “I5”]. There is quite a bit of discussion in this thread that I would recommend reviewing. Maybe drop the sort and see if that helps?

Your modified code snippet:

    function shipReport(){
    var shipOrder = allShips();
    var finalShip = [shipOrder[0],shipOrder[shipOrder.length-1]];
    return finalShip;

    }

#7

it does work, but shouldn’t the output be [‘B3’,'I5] instead according to the question? B3 is further west than C2…no? I’m confused @_@


#8

Yes, [B3, I5] is correct.


#9

@klau you are correct but as noted here multiple people passed with first and last but not necessarily most west and east. I have yet to see any clarification on what may have been occurring.

@Lighthouse @LighthouseJr – any chance we could get your input? Or a link to a thread if you have already done so? Thanks!