Code playground

I’m trying to figure out what I’m doing wrong, why does this code only print out “woo!”

So you have an array of backpacking items but are you not looping through those items. Hence it will always print woo!. Also you are comparing the object holder not the array items hence will not be equal to exaustion.

put a for loop for the backpack and then in the loop put the if statement. I hope that helps.


var backpacking = [
‘tree hammock’,


for(var element of backpacking)
if(element === ‘exaustion’)
else {

1 Like

Hey @Nate_McCarthy,

In addition to @Ahsen’s solution, you can also use Array Indexing to reference a specific value from your array within your if-else statement. For example:

if (backpacking[1] === 'exaustion') {
}  else {

H :slight_smile: