From 27302761e8a8429547becccd070b5b7a7abab69e Mon Sep 17 00:00:00 2001 From: hamza Date: Tue, 9 Aug 2022 17:01:34 +0100 Subject: [PATCH] DEV-3414 docs(SliceAdd):add subject --- subjects/sliceadd/README.md | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 subjects/sliceadd/README.md diff --git a/subjects/sliceadd/README.md b/subjects/sliceadd/README.md new file mode 100644 index 00000000..4974053f --- /dev/null +++ b/subjects/sliceadd/README.md @@ -0,0 +1,39 @@ +## sliceadd + +### Instructions + +- Write a function that takes a slice of integers and int and adds integer in the slice then returns the slice +- If the slice is empty, return a slice with the new value + +### Expected function + +```go +func SliceAdd(slice []int , num int) []int { + +} +``` + +### Usage + +Here is a possible program to test your function : + +```go +package main + +import ( + "fmt" +) + +func main() { + fmt.Println(SliceAdd([]int{1, 2, 3}, 4)) + fmt.Println(SliceAdd([]int{}, 4)) +} +``` + +And its output : + +```console +$ go run . +[1 2 3 4] +[4] +```