Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Going Further
Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Going Further
Button Combo Kata
You are working on a video game, and you need to calculate the base damage from a combo move the player enters on the controller.
You are given a string representing the buttons pressed by the player. These are the possible buttons:
A
B
X
Y
L
R
U
D
Player input might look like this: AUBDBDAAUXL
The base damage from a combo is equal to the number of buttons the player pressed in a row without pressing the same button twice in a row. Pressing the same button twice in a row ends the combo.
For the above example, the return value should be 7
, because after the 7th button was pressed (the A
button), that same button was pressed again and broke the combo.
Code Editor
Click "Run Tests" to execute your function and see the test results below.
Test Results
Run your code to see test results
Console Output
0 output lines