forked from root/public
Compare commits
9 Commits
master
...
1277-skipt
Author | SHA1 | Date |
---|---|---|
Hamza elkhatri | 61e2eb5ce4 | 2 years ago |
hamza | edeab949b6 | 2 years ago |
hamza | e507963971 | 2 years ago |
Hamza elkhatri | 1e184a2ca1 | 2 years ago |
Hamza elkhatri | 567772afa9 | 2 years ago |
Hamza elkhatri | f6826b23fc | 2 years ago |
Hamza elkhatri | 2463ea4a73 | 2 years ago |
hamza | 29fb4cbda8 | 2 years ago |
hamza | aa0d6ec508 | 2 years ago |
1 changed files with 39 additions and 0 deletions
@ -0,0 +1,39 @@
|
||||
## 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 |
||||
|
||||
```go |
||||
func AddFront(s string, slice []string) []string { |
||||
// your code here |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
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: |
||||
|
||||
```console |
||||
$ go run . |
||||
[Hello world] |
||||
[Hello world !] |
||||
[Hello] |
||||
``` |
Loading…
Reference in new issue