You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Hamza elkhatri 2f765363af add condition 2 years ago
..
README.md add condition 2 years ago

README.md

addfront

Instructions

Write a function that takes a string and a slice of strings, this function will return a new slice of string with the given string prepended

  • If the given string is empty you only need to return the given slice

Expected function

func AddFront(s string, slice []string) []string {
    // your code here
}

Usage

Here is a possible program to test your function:

package main

import "fmt"

func main() {
    fmt.Println(AddFront("Hello", []string{"world"}))
    fmt.Println(AddFront("Hello", []string{"world", "!"}))
    fmt.Println(AddFront("Hello", []string{}))
}

and the output should be:

$ go run .
[Hello world]
[Hello world !]
[Hello]