I am trying to return an array with elements that have an ocean habitat https://code.sololearn.com/W1ghG2VMsoCi/?ref=app
5/25/2022 3:53:20 PM
steve Purpose8 Answers
New AnswerLook at checkCreatures() line 12, you should evaluate by using equality operator `==` rather than assignment operator `=` return element.habitat == "ocean";
steve Purpose It was the case. Ipang just elaborated on what I said cause I pointed out the return statement.
I believe it's because your check function is taking every key element passed into it and making the value ocean based on the return statement. I may be wrong though.
@justice I don't think that's the case,that's the pattern I use on some other occasions and it has always worked
steve Purpose When I said "Your check function..." the check function is checkCreatures(). "...is taking every key element passed into it... " The Key would be "lion". "... and making the value ocean... " The value was "jungle" and turned it into "ocean". "...based on the return statement." This is where Ipang expands on what I said and tells you that you should that instead of using the assignment operator, you should use the equality.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message