Input : A single string "aaababbcdff"
Output : Reduced string "abacd"
Problem : Delete each pair of adjacent letters that match from the above string.
let s="aaababbcdff";
let arr = s.split("");
for(let i=0;i<arr.length;i++){
if(arr[i]==arr[i+1]){
arr.splice(i,2);
}
}
s=arr.join("");
console.log(s);
Next Coding Challenge: Add all Integer in a string using JavaScript.
Top comments (2)
pure and lighter :)
And the code for this challenge is wrong! It's mistaken with the second challenge