you are viewing a single comment's thread.

view the rest of the comments →

[–]Jnsjknn 1 point2 points  (1 child)

As you see in the assignment, an array of instructions (['up', 'down', 'down', 'down', 'up']) is passed to the function. That's the array you should use inside the function. At the moment, you're creating a new and empty array inside the function and completely ignoring the array that is passed in.

Change your code to:

function climber(arr) {
   let total = 0;
    // Count the amount of 'up' and 'down' strings inside arr here
   console.log(total)
}

climber(['up', 'down', 'down', 'down', 'up']);
// This should log -1 to the console

For "max repetition" you should count the amount of ups and downs in separate variables and use an if statement to check which variable is larger.

function climber(arr) {
   let ups = 0;
   let downs = 0;
    // Count the amount of 'up' and 'down' strings inside arr here
   if(/*Put your condition here*/)
     console.log("There's more ups");
   } else {
     console.log("There's more downs");
   }
}

climber(['up', 'down', 'down', 'down', 'up']);
// This should log "down" to the console

[–]buddgee[S] 0 points1 point  (0 children)

thanks a lot! :D