Opening your workspace…
Workspace/Coding room
Opening your workspace…
You’re making your way through a Pokémon cave and want to know how many Zubat you’ve passed between your current spot and the exit. Given the cave’s Pokémon encounters in order, count the Zubat from your current position through the exit, including both endpoints.
["Zubat","Geodude","Zubat","Golbat"], 0, 3Output2The inclusive stretch from index 0 to 3 contains two Zubat.
["Zubat","Zubat","Zubat","Zubat"], 1, 2Output2Only indices 1 and 2 are between the trainer’s position and the exit.
Include both the current position and the exit in the count.
function solve(encounters, currentPosition, exitPosition) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.