Hi there, can you please help me writing this code?

Specifications: Write a shorter function (words [] string) int that, given a slice of strings, returns the length of the shortest string in terms of bytes. To test it you can use the main shown in the image below.

What have you tried so far to solve this exercise? What are your troubles making it work? What output do you get? Which do you expect?

1 Like

yes I start to write it but I cannot how to go on to solve it

Can you please be more specific? What exactly is it what you have problems with?

As you post some screenshot that looks as if it has been taken from a courses book or website, I assume you are asking us to do your home work. We usually do not do peoples home work, but instead help them to overcome their problems and therefore solve the exercise on their own, ultimately learning something in the process.

Also in general I assume, that everything necessary to solve such an assignment is explained in the recent coursematerial.

can I please have some advices or tips to solve it? I’m just asking for these

It is easier to give you the tips based on what you already have. Otherwise the tipp will be to implement a function that does whats asked for in the exercise.

Any other hint we might give you, might be something that you already know. A waste of time for both of us…

1 Like

seems like you should do you school assignments by yourself :smile:

1 Like

Hi,

This link may help you : https://www.golangprograms.com/golang-get-number-of-bytes-and-runes-in-a-string.html

The function is just a loop (like the one in your main() code) with a comparison to store the minimum value and return that value at the end.
Remember to initialize the value to compare with a large value.
I’m not doing your exercise… but if you can’t do it with my explanation… :wink: