---
title: Delete the Repeats
tags: challenge-zone
---
<style>
.center{
text-align: center;
}
.blue {
color: #51c1e9;
}
.blue-underline {
color: #51c1e9;
text-decoration: underline;
}
.sub-t {
color: #FF0000;
font-size: 22px;
}
.header {
font-size: 28px;
}
.sub-header {
font-size: 29px;
}
.important {
color: #E80D20;
}
.big {
font-size: 38px;
font-weight: bolder;
}
.green {
color: #39a928;
font-weight: bold;
}
.red {
color: #db2b3d;
font-weight: bold;
}
.small {
font-size: 12px;
}
.head {
font-weight: bold;
font-size: 25px;
}
</style>
<p class="blue big center">Delete the Repeats</p>
<hr>
:::warning
If you're viewing this on the Challenge Zone website, you can click [here](https://hackmd.io/@ASC/deleteTheRepeats) to open the challenge in a new tab.
:::
### <p class="head">Scenario</p>
A new app has been developed that recongizes words containing repeated characters that are adjacent to each other. This app automatically detects these repeated characters and instantly deletes them from the word, creating new interesting words.
---
### <p class="head">Task</p>
Given a `String` containing characters from the alphabet [a-z, A-Z], write an `alterCharacters` function to delete all repeating characters that are adjacent to each other and return the total number of deleted characters.
---
### function `alterCharacters`
The `alterCharacters` function should accept a `String` argument and return an `Integer` value.
---
### <p class="head">Sample Results</p>
```javascript=
alterCharacters("AAABB") // --> 3
alterCharacters("BBB") // --> 2
alterCharacters("ZZZSSS") // --> 4
alterCharacters("CHASE") // --> 0
alterCharacters("AllStarCode") // --> 1
alterCharacters("LittleRedRidingHood") // --> 2
alterCharacters("") // --> 0
```
Your function should work for any `String` argument. DO NOT HARDCODE!