Daily Programming Challenge #2

Every day I am going to do a random programming challenge in Javascript.

Todays challenge:

you have a string “ddaaiillyypprrooggrraammeerr”. We want to remove all the consecutive duplicates and put them in a separate string, which yields two separate instances of the string “dailyprogramer”.

use this list for testing:
input: “balloons”
expected output: “balons” “lo”
input: “ddaaiillyypprrooggrraammeerr”
expected output: “dailyprogramer” “dailyprogramer”
input: “aabbccddeded”
expected output: “abcdeded” “abcd”
input: “flabby aapples”
expected output: “flaby aples” “bap”
reddit

This one was too easy. Here’s my solution: