Challenge 15 - Repeating Letters

👋 Welcome Gophers! In this challenge, you are tasked with implementing a function DoubleChars which will take in a string and then return another string which has every letter in the word doubled.

View Solution
package main

import "fmt"

func DoubleChars(original string) string {
  endString := make([]rune, 0, len(original)*2)
  for _, c := range original {
    endString = append(endString, c, c)
  return string(endString)

func main() {
  fmt.Println("Repeating Letters Challenge")

  original := "gophers"
  doubled := DoubleChars(original)
  fmt.Println(doubled) // ggoopphheerrss

Further Reading:

If you enjoyed this challenge, you may also enjoy some of the other challenges on this site:

Other Challenges